Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Interfaces

Type aliases

Variables

Functions

Type aliases

AnyConstructor: new (...args: any[]) => unknown

Type declaration

    • new (...args: any[]): unknown
    • A type that any constructor is assignable to. Use as a generic constraint (T extends AnyConstructor) and for function parameters (a: AnyConstructor). Use new (...args: unknown[]) => unknown instead for function return types.

      <created by @somebody1234>

      Parameters

      • Rest ...args: any[]

      Returns unknown

AnyFunction: (...args: any[]) => unknown

Type declaration

    • (...args: any[]): unknown
    • A type that any function is assignable to. Use as a generic constraint (T extends AnyFunction) and for function parameters (a: AnyFunction). Use (...args: unknown[]) => unknown instead for function return types.

      <created by @somebody1234>

      Parameters

      • Rest ...args: any[]

      Returns unknown

Arity0Fn: () => any

Type declaration

    • (): any
    • A function taking 0 arguments.

      deprecated

      Use () => unknown instead

      Returns any

Arity1Fn: (a: any) => any

Type declaration

    • (a: any): any
    • A function taking 1 argument.

      deprecated

      Use (a: any) => unknown instead

      Parameters

      • a: any

      Returns any

Arity2Fn: (a: any, b: any) => any

Type declaration

    • (a: any, b: any): any
    • A function taking 2 arguments.

      deprecated

      Use (a: any, b: any) => unknown instead

      Parameters

      • a: any
      • b: any

      Returns any

AssocPartialOne<K>: (<T>(val: T) => <U>(obj: U) => Record<K, T> & Omit<U, K>) & (<T, U>(val: T, obj: U) => Record<K, T> & Omit<U, K>)

Type parameters

  • K: keyof any

AtLeastOneFunctionsFlow<TArgs, TResult>: [(...args: TArgs) => any, ...((args: any) => any)[], (...args: any[]) => TResult] | [(...args: TArgs) => TResult]

Array of functions to compose/pipe with.

Type parameters

  • TArgs: any[]

  • TResult

AtLeastOneFunctionsFlowFromRightToLeft<TArgs, TResult>: [(...args: any) => TResult, ...((args: any) => any)[], (...args: TArgs) => any] | [(...args: TArgs) => TResult]

Type parameters

  • TArgs: any[]

  • TResult

CondPair<T, R>: [(...val: T) => boolean, (...val: T) => R]

R.cond's [predicate, transform] pair.

Type parameters

  • T: any[]

  • R

CondPairTypeguard<T, TFiltered, R>: [(value: T) => value is TFiltered, (value: TFiltered) => R]

R.cond's [predicate, transform] pair in a typeguarded version

Type parameters

  • T

  • TFiltered: T

  • R

EQ: 0

a is equal to b

Evolvable<E>: { [ P in keyof E]?: Evolved<E[P]> }

Represents all objects evolvable with Evolver E

Type parameters

Evolve<O, E>: { [ P in keyof O]: P extends keyof E ? EvolveValue<O[P], E[P]> : O[P] }

Type parameters

Evolver<T>: { [ key in keyof Partial<T>]: ((value: T[key]) => T[key]) | (T[key] extends Evolvable<any> ? Evolver<T[key]> : never) }

A set of transformation to run as part of an evolve

Type parameters

  • T: Evolvable<any> = any

    the type to be evolved

Falsy: undefined | null | 0 | "" | false

All falsy JavaScript values representable by the type system.

note

Actually there are six (seven) falsy values in JS - the sixth being NaN; the seventh being document.all. However NaN is not a valid literal type, and document.all is an object so it's probably not a good idea to add it either.

Fn: (...args: any[]) => unknown

Type declaration

    • (...args: any[]): unknown
    • A type representing any function. Useful as a generic constraint.

      Parameters

      • Rest ...args: any[]

      Returns unknown

Functor<A>: { fantasy-land/map: any } | { map: any }

A functor satisfying the FantasyLand spec

Type parameters

  • A

GT: 1

a is greater than b

IfFunctionsArgumentsDoNotOverlap<T, ErrorMsg>: HasNever<LargestArgumentsList<T>> extends true ? ErrorMsg : unknown

Checks if corresponding types of arguments in functions overlap(have at least one type in common, except never)

Returns unknown if arguments types overlap, else returns ErrorMsg

Type parameters

  • T: ReadonlyArray<Fn>

    Type to check

    <created by @valerii15298>

  • ErrorMsg: string

InputTypesOfFns<A>: A extends [infer H, ...infer R] ? H extends Fn ? R extends Fn[] ? [Parameters<H>[0], ...InputTypesOfFns<R>] : [] : [] : []

Converts an array of functions taking a single parameter to an array of their parameter types.

Type parameters

  • A: ReadonlyArray<Fn>

    The array of functions

KeyValuePair<K, V>: [K, V]

A pair containing the key and corresponding value of an object.

Type parameters

  • K

    Key type

  • V

    Value type

LT: -1

a is less than b

LargestArgumentsList<T>: T extends readonly [(...args: infer Args) => any, ...infer Rest] ? MergeArrays<LargestArgumentsList<Rest>, Args> : readonly []

Given array of functions will return new array which will be constructed merging all functions parameters array using mergeArrays generic.

If provided array is not array of functions, return type will be empty array([])

Type parameters

  • T: ReadonlyArray<any>

    Array of functions

    <created by @valerii15298>

Lens<S, A>: (functorFactory: (a: A) => Functor<A>) => (s: S) => Functor<S>

Type parameters

  • S

    Type of the full object

  • A

    Type of the lens focus

Type declaration

Merge<O1, O2, Depth>: O.MergeUp<T.ObjectOf<O1>, T.ObjectOf<O2>, Depth, 1>

Merge an object O1 with O2

Type parameters

  • O1: object

  • O2: object

  • Depth: "flat" | "deep"

    O1 & O2 are intersected with [] so that we can handle the scenario where we merge arrays (like ramda). Ramda removes array props when merging arrays, and thus only keeps own properties. This is what ObjectOf does.

    => ramda's merge functions are 100% properly typed.

    <created by @pirix-gh>

MergeAll<Os>: O.AssignUp<{}, Os, "flat", 1> extends infer M ? {} extends M ? T.UnionOf<Os> : M : never

Merge multiple objects Os with each other

Type parameters

  • Os: readonly object[]

    It essentially works like Merge, since the utility MergeUp is used by AssignUp internally.

    <created by @pirix-gh>

ObjPred<T>: (value: any, key: unknown extends T ? string : keyof T) => boolean

Type parameters

  • T = unknown

Type declaration

    • (value: any, key: unknown extends T ? string : keyof T): boolean
    • Predicate for an object containing the key.

      Parameters

      • value: any
      • key: unknown extends T ? string : keyof T

      Returns boolean

ObjectHavingSome<Key>: A.Clean<{ [ K in Key]: { [ P in K]: unknown } }[Key]>

An object with at least one of its properties beeing of type Key.

example
// $ExpectType { foo: unknown } | { bar: unknown }
type Foo = ObjectHavingSome<"foo" | "bar">

Type parameters

  • Key: string

Ord: number | string | boolean | Date

Values that can be compared using the relational operators </<=/>/>=

Ordering: LT | EQ | GT

Represents two values' order

Path: ReadonlyArray<number | string>
Placeholder: A.x & { @@functional/placeholder: true }

A placeholder used to skip parameters, instead adding a parameter to the returned function.

Pred<T>: (...a: T) => boolean

Type parameters

  • T: any[] = any[]

Type declaration

    • (...a: T): boolean
    • Takes a lists of arguments and returns either true or false.

      Classical predicates only take one argument, but since ramda supports multiple arguments, we also use them like that.

      Note that these predicates, don't represent typeguards, meaning when this type is used, we can't get type narrowing.

      see

      PredTypeguard for the typeguard version of this.

      Parameters

      • Rest ...a: T

      Returns boolean

PredTypeguard<T, TTypeguarded>: (a: T) => a is TTypeguarded

Type parameters

  • T

  • TTypeguarded: T

Type declaration

    • (a: T): a is TTypeguarded
    • Takes an argument and returns either true or false.

      This is usually used as an overload before Pred. If you would this type alone, the function would required to be a typeguard, meaning a simple function just returning a boolean wouldn't satisfy this constrain.

      Parameters

      • a: T

      Returns a is TTypeguarded

ReturnTypesOfFns<A>: A extends readonly [(...args: any[]) => infer H, ...infer R] ? R extends readonly Fn[] ? readonly [H, ...ReturnTypesOfFns<R>] : readonly [] : readonly []

Converts an array of functions to an array of their return types.

Type parameters

  • A: ReadonlyArray<Fn>

    The array of functions

Take<N, Tuple, ReturnTuple>: ReturnTuple["length"] extends N ? ReturnTuple : Tuple extends [infer X, ...infer Xs] ? Take<N, Xs, [...ReturnTuple, X]> : never

Take first N types of an Tuple

Type parameters

  • N: number

    Length of prefix to take

  • Tuple: any[]

    Input tuple type

  • ReturnTuple: any[] = []

ToTupleOfArray<Tuple>: Tuple extends [] ? [] : Tuple extends [infer X, ...infer Xs] ? [X[], ...ToTupleOfArray<Xs>] : never

Map tuple of ordinary type to tuple of array type [string, number] -> [string[], number[]]

Type parameters

  • Tuple: any[]

ToTupleOfFunction<R, Tuple>: Tuple extends [] ? [] : Tuple extends [infer X, ...infer Xs] ? [(arg: R) => X, ...ToTupleOfFunction<R, Xs>] : never

Map tuple of ordinary type to tuple of function type

Type parameters

  • R

    Parameter type of every function

  • Tuple: any[]

    Return type of every function

Tuple<T, N>: N extends N ? number extends N ? T[] : _TupleOf<T, N, []> : never

A homogeneous tuple of length N.

Type parameters

  • T

    Type of every element of the tuple

  • N: number

    Length of the tuple

ValueOfRecord<R>: R extends Record<any, infer T> ? T : never

The type of the values of a record.

deprecated

Use T[keyof T] instead.

Type parameters

  • R

    The record.

ValueOfUnion<T>: T extends infer U ? U[keyof U] : never

If T is a union, T[keyof T] (cf. map and values in index.d.ts) contains the types of object values that are common across the union (i.e., an intersection). Because we want to include the types of all values, including those that occur in some, but not all members of the union, we first define ValueOfUnion.

see

https://stackoverflow.com/a/60085683

Type parameters

  • T

    The (possible) union

mergeArrWithLeft<T1, T2>: readonly [...{ readonly [ Index in keyof T1]: Index extends keyof T2 ? Intersection<T1[Index], T2[Index]> : T1[Index] }]

Merge second array with first one, resulting array will have the same length as array T1, every item in new array will be item from first array(T1) by corresponding index intersected with item from second array(also with the same index) if such exist

examples: mergeArrWithLeft<[1, number, number, string], [number, 2, 7]> => [1, 2, 7, string] mergeArrWithLeft<[1, string], [number, "exact text", number, any]> => [1, "exact text"]

Type parameters

  • T1: ReadonlyArray<any>

  • T2: ReadonlyArray<any>

    <created by @valerii15298>

Variables

A special placeholder value used to specify "gaps" within curried functions, allowing partial application of any combination of arguments, regardless of their positions.

If g is a curried ternary function and _ is R.__, the following are equivalent:

  • g(1, 2, 3)
  • g(_, 2, 3)(1)
  • g(_, _, 3)(1)(2)
  • g(_, _, 3)(1, 2)
  • g(_, 2, _)(1, 3)
  • g(_, 2)(1)(3)
  • g(_, 2)(1, 3)
  • g(_, 2)(_, 3)(1)
example
const greet = R.replace('{name}', R.__, 'Hello, {name}!');
greet('Alice'); //=> 'Hello, Alice!'

Functions

  • F(...args: unknown[]): false
  • A function that always returns false. Any passed in parameters are ignored.

    See also T.

    example
    R.F(); //=> false
    

    Parameters

    • Rest ...args: unknown[]

    Returns false

  • T(...args: unknown[]): true
  • A function that always returns true. Any passed in parameters are ignored.

    See also F.

    example
    R.T(); //=> true
    

    Parameters

    • Rest ...args: unknown[]

    Returns true

  • add(a: number, b: number): number
  • add(a: number): (b: number) => number
  • Adds two values. Equivalent to a + b but curried.

    example
    R.add(2, 3);       //=>  5
    R.add(7)(10); //=> 17

    Parameters

    • a: number
    • b: number

    Returns number

  • Parameters

    • a: number

    Returns (b: number) => number

      • (b: number): number
      • Parameters

        • b: number

        Returns number

  • addIndex<T>(fn: (f: (item: T) => void, list: readonly T[]) => T[]): _.F.Curry<(a: (item: T, idx: number, list: T[]) => void, b: readonly T[]) => T[]>
  • addIndex<T>(fn: (f: (item: T) => boolean, list: readonly T[]) => T[]): _.F.Curry<(a: (item: T, idx: number, list: T[]) => boolean, b: readonly T[]) => T[]>
  • addIndex<T, U>(fn: (f: (item: T) => U, list: readonly T[]) => U[]): _.F.Curry<(a: (item: T, idx: number, list: T[]) => U, b: readonly T[]) => U[]>
  • addIndex<T, U>(fn: (f: (acc: U, item: T) => U, aci: U, list: readonly T[]) => U): _.F.Curry<(a: (acc: U, item: T, idx: number, list: T[]) => U, b: U, c: readonly T[]) => U>
  • Creates a new list iteration function from an existing one by adding two new parameters to its callback function: the current index, and the entire list.

    This would turn, for instance, R.map function into one that more closely resembles Array.prototype.map.

    note

    This will only work for functions in which the iteration callback function is the first parameter, and where the list is the last parameter. (This latter might be unimportant if the list parameter is not used.)

    See also subtract.

    example
    const mapIndexed = R.addIndex(R.map);
    mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']);
    //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r']

    Type parameters

    • T

    Parameters

    • fn: (f: (item: T) => void, list: readonly T[]) => T[]
        • (f: (item: T) => void, list: readonly T[]): T[]
        • Parameters

          • f: (item: T) => void
              • (item: T): void
              • Parameters

                • item: T

                Returns void

          • list: readonly T[]

          Returns T[]

    Returns _.F.Curry<(a: (item: T, idx: number, list: T[]) => void, b: readonly T[]) => T[]>

  • Type parameters

    • T

    Parameters

    • fn: (f: (item: T) => boolean, list: readonly T[]) => T[]
        • (f: (item: T) => boolean, list: readonly T[]): T[]
        • Parameters

          • f: (item: T) => boolean
              • (item: T): boolean
              • Parameters

                • item: T

                Returns boolean

          • list: readonly T[]

          Returns T[]

    Returns _.F.Curry<(a: (item: T, idx: number, list: T[]) => boolean, b: readonly T[]) => T[]>

  • Type parameters

    • T

    • U

    Parameters

    • fn: (f: (item: T) => U, list: readonly T[]) => U[]
        • (f: (item: T) => U, list: readonly T[]): U[]
        • Parameters

          • f: (item: T) => U
              • (item: T): U
              • Parameters

                • item: T

                Returns U

          • list: readonly T[]

          Returns U[]

    Returns _.F.Curry<(a: (item: T, idx: number, list: T[]) => U, b: readonly T[]) => U[]>

  • Type parameters

    • T

    • U

    Parameters

    • fn: (f: (acc: U, item: T) => U, aci: U, list: readonly T[]) => U
        • (f: (acc: U, item: T) => U, aci: U, list: readonly T[]): U
        • Parameters

          • f: (acc: U, item: T) => U
              • (acc: U, item: T): U
              • Parameters

                • acc: U
                • item: T

                Returns U

          • aci: U
          • list: readonly T[]

          Returns U

    Returns _.F.Curry<(a: (acc: U, item: T, idx: number, list: T[]) => U, b: U, c: readonly T[]) => U>

  • adjust<T>(index: number, fn: (a: T) => T, list: readonly T[]): T[]
  • adjust<T>(index: number, fn: (a: T) => T): (list: readonly T[]) => T[]
  • Applies a function to the value at the given index of an array, returning a new copy of the array with the element at the given index replaced with the result of the function application.

    See also update.

    example
    R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']);      //=> ['a', 'B', 'c', 'd']
    R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c', 'D']

    Type parameters

    • T

    Parameters

    • index: number
    • fn: (a: T) => T
        • (a: T): T
        • Parameters

          • a: T

          Returns T

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • index: number
    • fn: (a: T) => T
        • (a: T): T
        • Parameters

          • a: T

          Returns T

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • all<T>(fn: (a: T) => boolean, list: readonly T[]): boolean
  • all<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean
  • Returns true if all elements of the list match the predicate, false if there are any that don't.

    Dispatches to the all method of the second argument, if present.

    Acts as a transducer if a transformer is given in list position.

    See also any, none, transduce.

    example
    const equals3 = R.equals(3);
    R.all(equals3)([3, 3, 3, 3]); //=> true
    R.all(equals3)([3, 3, 1, 3]); //=> false

    Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns boolean

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns (list: readonly T[]) => boolean

      • (list: readonly T[]): boolean
      • Parameters

        • list: readonly T[]

        Returns boolean

  • Takes a list of predicates and returns a predicate that returns true for a given list of arguments if every one of the provided predicates is satisfied by those arguments.

    The function returned is a curried function whose arity matches that of the highest-arity predicate.

    See also anyPass.

    example
    type Card = { rank: string; suit: string; };

    const isQueen = R.propEq('rank', 'Q');
    const isSpade = R.propEq('suit', '♠︎');
    const isQueenOfSpades = R.allPass<R.Pred<[Card]>>([isQueen, isSpade]);

    isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false
    isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true

    Type parameters

    • T

    • TF1

    • TF2

    Parameters

    Returns (a: T) => a is TF1 & TF2

      • (a: T): a is TF1 & TF2
      • Takes a list of predicates and returns a predicate that returns true for a given list of arguments if every one of the provided predicates is satisfied by those arguments.

        The function returned is a curried function whose arity matches that of the highest-arity predicate.

        See also anyPass.

        example
        type Card = { rank: string; suit: string; };

        const isQueen = R.propEq('rank', 'Q');
        const isSpade = R.propEq('suit', '♠︎');
        const isQueenOfSpades = R.allPass<R.Pred<[Card]>>([isQueen, isSpade]);

        isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false
        isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true

        Parameters

        • a: T

        Returns a is TF1 & TF2

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    Parameters

    Returns (a: T) => a is TF1 & TF2 & TF3

      • (a: T): a is TF1 & TF2 & TF3
      • Parameters

        • a: T

        Returns a is TF1 & TF2 & TF3

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    Parameters

    Returns (a: T) => a is TF1 & TF2 & TF3

      • (a: T): a is TF1 & TF2 & TF3
      • Parameters

        • a: T

        Returns a is TF1 & TF2 & TF3

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    Parameters

    Returns (a: T) => a is TF1 & TF2 & TF3 & TF4

      • (a: T): a is TF1 & TF2 & TF3 & TF4
      • Parameters

        • a: T

        Returns a is TF1 & TF2 & TF3 & TF4

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    Parameters

    Returns PredTypeguard<T, TF1 & TF2 & TF3 & TF4 & TF5>

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    • TF6

    Parameters

    Returns PredTypeguard<T, TF1 & TF2 & TF3 & TF4 & TF5 & TF6>

  • Type parameters

    Parameters

    • preds: readonly F[]

    Returns F

  • always<T>(val: T): (...args: unknown[]) => T
  • Returns a function that always returns the given value.

    note

    For non-primitives the value returned is a reference to the original value.

    This function is known as const, constant, or K (for K combinator) in other languages and libraries.

    example
    const t = R.always('Tee');
    t(); //=> 'Tee'

    Type parameters

    • T

    Parameters

    • val: T

    Returns (...args: unknown[]) => T

      • (...args: unknown[]): T
      • Returns a function that always returns the given value.

        note

        For non-primitives the value returned is a reference to the original value.

        This function is known as const, constant, or K (for K combinator) in other languages and libraries.

        example
        const t = R.always('Tee');
        t(); //=> 'Tee'

        Parameters

        • Rest ...args: unknown[]

        Returns T

  • and<T, U>(a: T, b: U): T | U
  • and<T>(a: T): <U>(b: U) => T | U
  • A function that returns the first argument if it's falsy otherwise the second argument.

    See also both, or, xor.

    note

    This is not short-circuited, meaning that if expressions are passed they are both evaluated.

    example
    R.and(true, true); //=> true
    R.and(true, false); //=> false
    R.and(false, true); //=> false
    R.and(false, false); //=> false

    Type parameters

    • T

    • U

    Parameters

    • a: T
    • b: U

    Returns T | U

  • Type parameters

    • T

    Parameters

    • a: T

    Returns <U>(b: U) => T | U

      • <U>(b: U): T | U
      • Type parameters

        • U

        Parameters

        • b: U

        Returns T | U

  • andThen<A, B>(onSuccess: (a: A) => B | Promise<B>, promise: Promise<A>): Promise<B>
  • andThen<A, B>(onSuccess: (a: A) => B | Promise<B>): (promise: Promise<A>) => Promise<B>
  • Returns the result of applying the onSuccess function to the value inside a successfully resolved Promise. This is useful for working with Promises inside function compositions.

    See also otherwise.

    example
    type Query = { query: { email: string; }; };

    const makeQuery = (email: string) => ({ query: { email }});
    const fetchMember = (request: Query) =>
    Promise.resolve({ firstName: 'Bob', lastName: 'Loblaw', id: 42 });

    //getMemberName :: String -> Promise ({ firstName, lastName })
    const getMemberName = R.pipe(
    makeQuery,
    fetchMember,
    R.andThen(R.pick(['firstName', 'lastName']))
    );

    getMemberName('bob@gmail.com').then(console.log);

    Type parameters

    • A

    • B

    Parameters

    • onSuccess: (a: A) => B | Promise<B>
        • (a: A): B | Promise<B>
        • Parameters

          • a: A

          Returns B | Promise<B>

    • promise: Promise<A>

    Returns Promise<B>

  • Type parameters

    • A

    • B

    Parameters

    • onSuccess: (a: A) => B | Promise<B>
        • (a: A): B | Promise<B>
        • Parameters

          • a: A

          Returns B | Promise<B>

    Returns (promise: Promise<A>) => Promise<B>

      • (promise: Promise<A>): Promise<B>
      • Parameters

        • promise: Promise<A>

        Returns Promise<B>

  • any<T>(fn: (a: T) => boolean, list: readonly T[]): boolean
  • any<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean
  • Returns true if at least one of elements of the list match the predicate, false otherwise.

    Dispatches to the any method of the second argument, if present.

    Acts as a transducer if a transformer is given in list position.

    See also all, none, transduce.

    example
    const lessThan0 = R.flip(R.lt)(0);
    const lessThan2 = R.flip(R.lt)(2);
    R.any(lessThan0)([1, 2]); //=> false
    R.any(lessThan2)([1, 2]); //=> true

    Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns boolean

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns (list: readonly T[]) => boolean

      • (list: readonly T[]): boolean
      • Parameters

        • list: readonly T[]

        Returns boolean

  • Takes a list of predicates and returns a predicate that returns true for a given list of arguments if at least one of the provided predicates is satisfied by those arguments.

    The function returned is a curried function whose arity matches that of the highest-arity predicate.

    See also allPass.

    example
    type Card = { rank: string; suit: string; };

    const isClub = R.propEq('suit', '♣');
    const isSpade = R.propEq('suit', '♠');
    const isBlackCard = R.anyPass<R.Pred<[Card]>>([isClub, isSpade]);

    isBlackCard({rank: '10', suit: '♣'}); //=> true
    isBlackCard({rank: 'Q', suit: '♠'}); //=> true
    isBlackCard({rank: 'Q', suit: '♦'}); //=> false

    Type parameters

    • T

    • TF1

    • TF2

    Parameters

    Returns (a: T) => a is TF1 | TF2

      • (a: T): a is TF1 | TF2
      • Takes a list of predicates and returns a predicate that returns true for a given list of arguments if at least one of the provided predicates is satisfied by those arguments.

        The function returned is a curried function whose arity matches that of the highest-arity predicate.

        See also allPass.

        example
        type Card = { rank: string; suit: string; };

        const isClub = R.propEq('suit', '♣');
        const isSpade = R.propEq('suit', '♠');
        const isBlackCard = R.anyPass<R.Pred<[Card]>>([isClub, isSpade]);

        isBlackCard({rank: '10', suit: '♣'}); //=> true
        isBlackCard({rank: 'Q', suit: '♠'}); //=> true
        isBlackCard({rank: 'Q', suit: '♦'}); //=> false

        Parameters

        • a: T

        Returns a is TF1 | TF2

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    Parameters

    Returns (a: T) => a is TF1 | TF2 | TF3

      • (a: T): a is TF1 | TF2 | TF3
      • Parameters

        • a: T

        Returns a is TF1 | TF2 | TF3

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    Parameters

    Returns (a: T) => a is TF1 | TF2 | TF3

      • (a: T): a is TF1 | TF2 | TF3
      • Parameters

        • a: T

        Returns a is TF1 | TF2 | TF3

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    Parameters

    Returns (a: T) => a is TF1 | TF2 | TF3 | TF4

      • (a: T): a is TF1 | TF2 | TF3 | TF4
      • Parameters

        • a: T

        Returns a is TF1 | TF2 | TF3 | TF4

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    Parameters

    Returns PredTypeguard<T, TF1 | TF2 | TF3 | TF4 | TF5>

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    • TF6

    Parameters

    Returns PredTypeguard<T, TF1 | TF2 | TF3 | TF4 | TF5 | TF6>

  • Type parameters

    Parameters

    • preds: readonly F[]

    Returns F

  • ap<T, U>(fns: readonly ((a: T) => U)[], vs: readonly T[]): U[]
  • ap<T, U>(fns: readonly ((a: T) => U)[]): (vs: readonly T[]) => U[]
  • ap<R, A, B>(fn: (r: R, a: A) => B, fn1: (r: R) => A): (r: R) => B
  • ap applies a list of functions to a list of values.

    Dispatches to the ap method of the first argument, if present. Also treats curried functions as applicatives.

    example
    R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6]
    R.ap([R.concat('tasty '), R.toUpper], ['pizza', 'salad']); //=> ["tasty pizza", "tasty salad", "PIZZA", "SALAD"]

    // R.ap can also be used as S combinator
    // when only two functions are passed
    R.ap((s, s2) => R.concat(s, s2), R.toUpper)('Ramda') //=> 'RamdaRAMDA'

    Type parameters

    • T

    • U

    Parameters

    • fns: readonly ((a: T) => U)[]
    • vs: readonly T[]

    Returns U[]

  • Type parameters

    • T

    • U

    Parameters

    • fns: readonly ((a: T) => U)[]

    Returns (vs: readonly T[]) => U[]

      • (vs: readonly T[]): U[]
      • Parameters

        • vs: readonly T[]

        Returns U[]

  • Type parameters

    • R

    • A

    • B

    Parameters

    • fn: (r: R, a: A) => B
        • (r: R, a: A): B
        • Parameters

          • r: R
          • a: A

          Returns B

    • fn1: (r: R) => A
        • (r: R): A
        • Parameters

          • r: R

          Returns A

    Returns (r: R) => B

      • (r: R): B
      • Parameters

        • r: R

        Returns B

  • aperture<N, T>(n: N, list: readonly T[]): Tuple<T, N>[] | []
  • aperture<N>(n: N): <T>(list: readonly T[]) => Tuple<T, N>[] | []
  • Returns a new list, composed of n-tuples of consecutive elements. If n is greater than the length of the list, an empty list is returned.

    Acts as a transducer if a transformer is given in list position.

    See also transduce.

    example
    R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]]
    R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
    R.aperture(7, [1, 2, 3, 4, 5]); //=> []

    Type parameters

    • N: number

    • T

    Parameters

    • n: N
    • list: readonly T[]

    Returns Tuple<T, N>[] | []

  • Type parameters

    • N: number

    Parameters

    • n: N

    Returns <T>(list: readonly T[]) => Tuple<T, N>[] | []

      • <T>(list: readonly T[]): Tuple<T, N>[] | []
      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns Tuple<T, N>[] | []

  • append<T>(el: T, list: readonly T[]): T[]
  • append<T>(el: T): (list: readonly T[]) => T[]
  • Returns a new list containing the contents of the given list, followed by the given element.

    See also prepend.

    example
    R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests']
    R.append('tests', []); //=> ['tests']
    R.append<string | string[]>(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']]

    Type parameters

    • T

    Parameters

    • el: T
    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • el: T

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • apply<F>(fn: F, args: Parameters<F>): ReturnType<F>
  • apply<F>(fn: F): (args: Parameters<F>) => ReturnType<F>
  • Applies function fn to the argument list args. This is useful for creating a fixed-arity function from a variadic function. fn should be a bound function if context is significant.

    See also call, unapply.

    Type parameters

    Parameters

    • fn: F
    • args: Parameters<F>

    Returns ReturnType<F>

  • Type parameters

    Parameters

    • fn: F

    Returns (args: Parameters<F>) => ReturnType<F>

      • (args: Parameters<F>): ReturnType<F>
      • Parameters

        • args: Parameters<F>

        Returns ReturnType<F>

  • applySpec<Obj>(obj: Obj): (...args: Parameters<Obj[keyof Obj]>) => { [ Key in keyof Obj]: ReturnType<Obj[Key]> }
  • applySpec<T>(obj: any): (...args: unknown[]) => T
  • Given a spec object recursively mapping properties to functions, creates a function producing an object of the same structure, by mapping each property to the result of calling its associated function with the supplied arguments.

    See also converge, juxt.

    example
    const getMetrics = R.applySpec({
    sum: R.add,
    nested: { mul: R.multiply }
    });
    getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } }

    Type parameters

    Parameters

    • obj: Obj

    Returns (...args: Parameters<Obj[keyof Obj]>) => { [ Key in keyof Obj]: ReturnType<Obj[Key]> }

      • (...args: Parameters<Obj[keyof Obj]>): { [ Key in keyof Obj]: ReturnType<Obj[Key]> }
      • Given a spec object recursively mapping properties to functions, creates a function producing an object of the same structure, by mapping each property to the result of calling its associated function with the supplied arguments.

        See also converge, juxt.

        example
        const getMetrics = R.applySpec({
        sum: R.add,
        nested: { mul: R.multiply }
        });
        getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } }

        Parameters

        • Rest ...args: Parameters<Obj[keyof Obj]>

        Returns { [ Key in keyof Obj]: ReturnType<Obj[Key]> }

  • Type parameters

    • T

    Parameters

    • obj: any

    Returns (...args: unknown[]) => T

      • (...args: unknown[]): T
      • Parameters

        • Rest ...args: unknown[]

        Returns T

  • applyTo<T, U>(el: T, fn: (t: T) => U): U
  • applyTo<T>(el: T): <U>(fn: (t: T) => U) => U
  • Takes a value and applies a function to it.

    This function is also known as the thrush combinator.

    example
    const t42 = R.applyTo(42);
    t42(R.identity); //=> 42
    t42(R.add(1)); //=> 43

    Type parameters

    • T

    • U

    Parameters

    • el: T
    • fn: (t: T) => U
        • (t: T): U
        • Parameters

          • t: T

          Returns U

    Returns U

  • Type parameters

    • T

    Parameters

    • el: T

    Returns <U>(fn: (t: T) => U) => U

      • <U>(fn: (t: T) => U): U
      • Type parameters

        • U

        Parameters

        • fn: (t: T) => U
            • (t: T): U
            • Parameters

              • t: T

              Returns U

        Returns U

  • Makes an ascending comparator function out of a function that returns a value that can be compared with < and >.

    See also descend.

    example
    const byAge = R.ascend(R.prop<'age', number>('age'));
    const people = [
    { name: 'Emma', age: 70 },
    { name: 'Peter', age: 78 },
    { name: 'Mikhail', age: 62 },
    ];
    const peopleByYoungestFirst = R.sort(byAge, people);
    //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]

    Type parameters

    • T

    Parameters

    • fn: (obj: T) => Ord
        • Parameters

          • obj: T

          Returns Ord

    • a: T
    • b: T

    Returns Ordering

  • Type parameters

    • T

    Parameters

    • fn: (obj: T) => Ord
        • Parameters

          • obj: T

          Returns Ord

    Returns (a: T, b: T) => Ordering

  • assoc<T, U>(__: Placeholder, val: T, obj: U): <K>(prop: K) => Record<K, T> & Omit<U, K>
  • assoc<U, K>(prop: K, __: Placeholder, obj: U): <T>(val: T) => Record<K, T> & Omit<U, K>
  • assoc<T, U, K>(prop: K, val: T, obj: U): Record<K, T> & Omit<U, K>
  • assoc<T, K>(prop: K, val: T): <U>(obj: U) => Record<K, T> & Omit<U, K>
  • assoc<K>(prop: K): AssocPartialOne<K>
  • Makes a shallow clone of an object, setting or overriding the specified property with the given value.

    note

    This copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

    See also dissoc, pick.

    example
    R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
    

    Type parameters

    • T

    • U

    Parameters

    Returns <K>(prop: K) => Record<K, T> & Omit<U, K>

      • <K>(prop: K): Record<K, T> & Omit<U, K>
      • Makes a shallow clone of an object, setting or overriding the specified property with the given value.

        note

        This copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

        See also dissoc, pick.

        example
        R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
        

        Type parameters

        • K: string

        Parameters

        • prop: K

        Returns Record<K, T> & Omit<U, K>

  • Type parameters

    • U

    • K: string

    Parameters

    Returns <T>(val: T) => Record<K, T> & Omit<U, K>

      • <T>(val: T): Record<K, T> & Omit<U, K>
      • Type parameters

        • T

        Parameters

        • val: T

        Returns Record<K, T> & Omit<U, K>

  • Type parameters

    • T

    • U

    • K: string

    Parameters

    • prop: K
    • val: T
    • obj: U

    Returns Record<K, T> & Omit<U, K>

  • Type parameters

    • T

    • K: string

    Parameters

    • prop: K
    • val: T

    Returns <U>(obj: U) => Record<K, T> & Omit<U, K>

      • <U>(obj: U): Record<K, T> & Omit<U, K>
      • Type parameters

        • U

        Parameters

        • obj: U

        Returns Record<K, T> & Omit<U, K>

  • Type parameters

    • K: string

    Parameters

    • prop: K

    Returns AssocPartialOne<K>

  • assocPath<T, U>(__: Placeholder, val: T, obj: U): (path: Path) => U
  • assocPath<T, U>(path: Path, __: Placeholder, obj: U): (val: T) => U
  • assocPath<T, U>(path: Path, val: T, obj: U): U
  • assocPath<T, U>(path: Path, val: T): (obj: U) => U
  • assocPath<T, U>(path: Path): _.F.Curry<(a: T, b: U) => U>
  • Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and placing the specific value at the tail end of that path.

    note

    This copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

    See also dissocPath.

    example
    R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}}

    // Any missing or non-object keys in path will be overridden
    R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}}

    Type parameters

    • T

    • U

    Parameters

    Returns (path: Path) => U

      • Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and placing the specific value at the tail end of that path.

        note

        This copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

        See also dissocPath.

        example
        R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}}

        // Any missing or non-object keys in path will be overridden
        R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}}

        Parameters

        Returns U

  • Type parameters

    • T

    • U

    Parameters

    Returns (val: T) => U

      • (val: T): U
      • Parameters

        • val: T

        Returns U

  • Type parameters

    • T

    • U

    Parameters

    • path: Path
    • val: T
    • obj: U

    Returns U

  • Type parameters

    • T

    • U

    Parameters

    Returns (obj: U) => U

      • (obj: U): U
      • Parameters

        • obj: U

        Returns U

  • Type parameters

    • T

    • U

    Parameters

    Returns _.F.Curry<(a: T, b: U) => U>

  • binary<T>(fn: T): (...arg: _.T.Take<Parameters<T>, "2">) => ReturnType<T>
  • Wraps a function of any arity (including nullary) in a function that accepts exactly 2 parameters. Any extraneous parameters will not be passed to the supplied function.

    See also nAry, unary.

    example
    const takesThreeArgs = function(a: number, b: number, c: number) {
    return [a, b, c];
    };
    takesThreeArgs.length; //=> 3
    takesThreeArgs(1, 2, 3); //=> [1, 2, 3]

    const takesTwoArgs = R.binary(takesThreeArgs);
    takesTwoArgs.length; //=> 2
    // Only 2 arguments are passed to the wrapped function
    // @ts-expect-error TypeScript is designed to not let you do this
    takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]

    Type parameters

    Parameters

    • fn: T

    Returns (...arg: _.T.Take<Parameters<T>, "2">) => ReturnType<T>

      • (...arg: _.T.Take<Parameters<T>, "2">): ReturnType<T>
      • Wraps a function of any arity (including nullary) in a function that accepts exactly 2 parameters. Any extraneous parameters will not be passed to the supplied function.

        See also nAry, unary.

        example
        const takesThreeArgs = function(a: number, b: number, c: number) {
        return [a, b, c];
        };
        takesThreeArgs.length; //=> 3
        takesThreeArgs(1, 2, 3); //=> [1, 2, 3]

        const takesTwoArgs = R.binary(takesThreeArgs);
        takesTwoArgs.length; //=> 2
        // Only 2 arguments are passed to the wrapped function
        // @ts-expect-error TypeScript is designed to not let you do this
        takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]

        Parameters

        • Rest ...arg: _.T.Take<Parameters<T>, "2">

        Returns ReturnType<T>

  • bind<F, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>
  • bind<F, T>(fn: F): (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>
  • Creates a function that is bound to a context.

    note

    R.bind does not provide the additional argument-binding capabilities of Function.prototype.bind.

    example
    const log = R.bind(console.log, console);
    R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
    // logs {a: 2}

    Type parameters

    Parameters

    • fn: F
    • thisObj: T

    Returns (...args: Parameters<F>) => ReturnType<F>

      • (...args: Parameters<F>): ReturnType<F>
      • Creates a function that is bound to a context.

        note

        R.bind does not provide the additional argument-binding capabilities of Function.prototype.bind.

        example
        const log = R.bind(console.log, console);
        R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
        // logs {a: 2}

        Parameters

        • Rest ...args: Parameters<F>

        Returns ReturnType<F>

  • Type parameters

    Parameters

    • fn: F

    Returns (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>

      • (thisObj: T): (...args: Parameters<F>) => ReturnType<F>
      • Parameters

        • thisObj: T

        Returns (...args: Parameters<F>) => ReturnType<F>

          • (...args: Parameters<F>): ReturnType<F>
          • Parameters

            • Rest ...args: Parameters<F>

            Returns ReturnType<F>

  • both<T, TF1, TF2>(pred1: PredTypeguard<T, TF1>, pred2: PredTypeguard<T, TF2>): (a: T) => a is TF1 & TF2
  • both<T>(pred1: T, pred2: T): T
  • both<T>(pred1: T): (pred2: T) => T
  • A function which calls the two provided functions and returns the && of the results. It returns the result of the first function if it is falsy and the result of the second function otherwise.

    note

    This is short-circuited, meaning that the second function will not be invoked if the first returns a falsy value.

    In addition to functions, R.both also accepts any fantasy-land compatible applicative functor.

    See also either, and.

    example
    const gt10 = R.gt(R.__, 10)
    const lt20 = R.lt(R.__, 20)
    const f = R.both(gt10, lt20);
    f(15); //=> true
    f(30); //=> false

    Type parameters

    • T

    • TF1

    • TF2

    Parameters

    Returns (a: T) => a is TF1 & TF2

      • (a: T): a is TF1 & TF2
      • A function which calls the two provided functions and returns the && of the results. It returns the result of the first function if it is falsy and the result of the second function otherwise.

        note

        This is short-circuited, meaning that the second function will not be invoked if the first returns a falsy value.

        In addition to functions, R.both also accepts any fantasy-land compatible applicative functor.

        See also either, and.

        example
        const gt10 = R.gt(R.__, 10)
        const lt20 = R.lt(R.__, 20)
        const f = R.both(gt10, lt20);
        f(15); //=> true
        f(30); //=> false

        Parameters

        • a: T

        Returns a is TF1 & TF2

  • Type parameters

    Parameters

    • pred1: T
    • pred2: T

    Returns T

  • Type parameters

    Parameters

    • pred1: T

    Returns (pred2: T) => T

      • (pred2: T): T
      • Parameters

        • pred2: T

        Returns T

  • call<T>(fn: T, ...args: Parameters<T>): ReturnType<T>
  • Returns the result of calling its first argument with the remaining arguments. This is occasionally useful as a converging function for R.converge: the first branch can produce a function while the remaining branches produce values to be passed to that function as its arguments.

    See also apply.

    example
    R.call<(a: number, b: number) => number>(R.add, 1, 2); //=> 3

    const indentN = R.pipe(
    R.repeat(' '),
    R.join(''),
    R.replace(/^(?!$)/gm)
    );

    Type parameters

    Parameters

    • fn: T
    • Rest ...args: Parameters<T>

    Returns ReturnType<T>

  • chain<A, B, T>(fn: (n: A) => readonly B[], list: readonly A[]): B[]
  • chain<A, B, T>(fn: (n: A) => readonly B[]): (list: readonly A[]) => B[]
  • chain<A, B, R>(aToMb: (a: A, r: R) => B, Ma: (r: R) => A): (r: R) => B
  • chain<A, B, R>(aToMb: (a: A, r: R) => B): (Ma: (r: R) => A) => (r: R) => B
  • chain maps a function over a list and concatenates the results. chain is also known as flatMap in some libraries.

    Dispatches to the chain method of the second argument, if present, according to the FantasyLand Chain spec.

    If second argument is a function, chain(f, g)(x) is equivalent to f(g(x), x).

    Acts as a transducer if a transformer is given in list position.

    See also transduce.

    example
    const duplicate = <T>(n: T) => [n, n];
    R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3]

    R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1]

    Type parameters

    • A

    • B

    • T = never

    Parameters

    • fn: (n: A) => readonly B[]
        • (n: A): readonly B[]
        • Parameters

          • n: A

          Returns readonly B[]

    • list: readonly A[]

    Returns B[]

  • Type parameters

    • A

    • B

    • T = never

    Parameters

    • fn: (n: A) => readonly B[]
        • (n: A): readonly B[]
        • Parameters

          • n: A

          Returns readonly B[]

    Returns (list: readonly A[]) => B[]

      • (list: readonly A[]): B[]
      • Parameters

        • list: readonly A[]

        Returns B[]

  • Type parameters

    • A

    • B

    • R

    Parameters

    • aToMb: (a: A, r: R) => B
        • (a: A, r: R): B
        • Parameters

          • a: A
          • r: R

          Returns B

    • Ma: (r: R) => A
        • (r: R): A
        • Parameters

          • r: R

          Returns A

    Returns (r: R) => B

      • (r: R): B
      • Parameters

        • r: R

        Returns B

  • Type parameters

    • A

    • B

    • R

    Parameters

    • aToMb: (a: A, r: R) => B
        • (a: A, r: R): B
        • Parameters

          • a: A
          • r: R

          Returns B

    Returns (Ma: (r: R) => A) => (r: R) => B

      • (Ma: (r: R) => A): (r: R) => B
      • Parameters

        • Ma: (r: R) => A
            • (r: R): A
            • Parameters

              • r: R

              Returns A

        Returns (r: R) => B

          • (r: R): B
          • Parameters

            • r: R

            Returns B

  • clamp<T>(min: T, max: T, value: T): T
  • clamp<T>(min: T, max: T): (value: T) => T
  • clamp<T>(min: T): (max: T, value: T) => T
  • clamp<T>(min: T): (max: T) => (value: T) => T
  • Restricts a number to be within a range. Also works for other ordered types such as strings and Dates.

    example
    R.clamp(1, 10, -5) // => 1
    R.clamp(1, 10, 15) // => 10
    R.clamp(1, 10, 4) // => 4

    Type parameters

    • T

    Parameters

    • min: T
    • max: T
    • value: T

    Returns T

  • Type parameters

    • T

    Parameters

    • min: T
    • max: T

    Returns (value: T) => T

      • (value: T): T
      • Parameters

        • value: T

        Returns T

  • Type parameters

    • T

    Parameters

    • min: T

    Returns (max: T, value: T) => T

      • (max: T, value: T): T
      • Parameters

        • max: T
        • value: T

        Returns T

  • Type parameters

    • T

    Parameters

    • min: T

    Returns (max: T) => (value: T) => T

      • (max: T): (value: T) => T
      • Parameters

        • max: T

        Returns (value: T) => T

          • (value: T): T
          • Parameters

            • value: T

            Returns T

  • clone<T>(value: T): T
  • clone<T>(value: readonly T[]): T[]
  • Creates a deep copy of the source that can be used in place of the source object without retaining any references to it. The source object may contain (nested) Arrays and Objects, numbers, strings, booleans and Dates. Functions are assigned by reference rather than copied.

    Dispatches to a clone method if present.

    Note that if the source object has multiple nodes that share a reference, the returned object will have the same structure, but the references will be pointed to the location within the cloned value.

    example
    const objects = [{}, {}, {}];
    const objectsClone = R.clone(objects);
    objects === objectsClone; //=> false
    objects[0] === objectsClone[0]; //=> false

    Type parameters

    • T

    Parameters

    • value: T

    Returns T

  • Type parameters

    • T

    Parameters

    • value: readonly T[]

    Returns T[]

  • collectBy<T, K>(keyFn: (value: T) => K, list: readonly T[]): T[][]
  • collectBy<T, K>(keyFn: (value: T) => K): (list: readonly T[]) => T[][]
  • Splits a list into sub-lists, based on the result of calling a key-returning function on each element, and grouping the results according to values returned.

    See also groupBy, partition.

    example
    R.collectBy(R.prop('type'), [
    {type: 'breakfast', item: '☕️'},
    {type: 'lunch', item: '🌯'},
    {type: 'dinner', item: '🍝'},
    {type: 'breakfast', item: '🥐'},
    {type: 'lunch', item: '🍕'}
    ]);

    // [ [ {type: 'breakfast', item: '☕️'},
    // {type: 'breakfast', item: '🥐'} ],
    // [ {type: 'lunch', item: '🌯'},
    // {type: 'lunch', item: '🍕'} ],
    // [ {type: 'dinner', item: '🍝'} ] ]

    Type parameters

    • T

    • K: PropertyKey

    Parameters

    • keyFn: (value: T) => K
        • (value: T): K
        • Parameters

          • value: T

          Returns K

    • list: readonly T[]

    Returns T[][]

  • Type parameters

    • T

    • K: PropertyKey

    Parameters

    • keyFn: (value: T) => K
        • (value: T): K
        • Parameters

          • value: T

          Returns K

    Returns (list: readonly T[]) => T[][]

      • (list: readonly T[]): T[][]
      • Parameters

        • list: readonly T[]

        Returns T[][]

  • comparator<T>(pred: (a: T, b: T) => boolean): (x: T, y: T) => Ordering
  • Makes a comparator function out of a function that reports whether the first element is less than the second.

    example
    type Person = { name: string; age: number; };

    const byAge = R.comparator<Person>((a, b) => a.age < b.age);
    const people = [
    { name: 'Emma', age: 70 },
    { name: 'Peter', age: 78 },
    { name: 'Mikhail', age: 62 },
    ];
    const peopleByIncreasingAge = R.sort(byAge, people);
    //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]

    Type parameters

    • T

    Parameters

    • pred: (a: T, b: T) => boolean
        • (a: T, b: T): boolean
        • Parameters

          • a: T
          • b: T

          Returns boolean

    Returns (x: T, y: T) => Ordering

      • Makes a comparator function out of a function that reports whether the first element is less than the second.

        example
        type Person = { name: string; age: number; };

        const byAge = R.comparator<Person>((a, b) => a.age < b.age);
        const people = [
        { name: 'Emma', age: 70 },
        { name: 'Peter', age: 78 },
        { name: 'Mikhail', age: 62 },
        ];
        const peopleByIncreasingAge = R.sort(byAge, people);
        //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]

        Parameters

        • x: T
        • y: T

        Returns Ordering

  • complement<T, TFiltered>(pred: (value: T) => value is TFiltered): (value: T) => value is Exclude<T, TFiltered>
  • complement<TArgs>(pred: (...args: TArgs) => unknown): (...args: TArgs) => boolean
  • Takes a function f and returns a function g such that if called with the same arguments when f returns a truthy value, g returns false and when f returns a falsy value g returns true.

    R.complement may be applied to any functor.

    See also not.

    example
    const isNotNil = R.complement(R.isNil);
    R.isNil(null); //=> true
    isNotNil(null); //=> false
    R.isNil(7); //=> false
    isNotNil(7); //=> true

    Type parameters

    • T

    • TFiltered

    Parameters

    • pred: (value: T) => value is TFiltered
        • (value: T): value is TFiltered
        • Parameters

          • value: T

          Returns value is TFiltered

    Returns (value: T) => value is Exclude<T, TFiltered>

      • (value: T): value is Exclude<T, TFiltered>
      • Takes a function f and returns a function g such that if called with the same arguments when f returns a truthy value, g returns false and when f returns a falsy value g returns true.

        R.complement may be applied to any functor.

        See also not.

        example
        const isNotNil = R.complement(R.isNil);
        R.isNil(null); //=> true
        isNotNil(null); //=> false
        R.isNil(7); //=> false
        isNotNil(7); //=> true

        Parameters

        • value: T

        Returns value is Exclude<T, TFiltered>

  • Type parameters

    • TArgs: any[]

    Parameters

    • pred: (...args: TArgs) => unknown
        • (...args: TArgs): unknown
        • Parameters

          • Rest ...args: TArgs

          Returns unknown

    Returns (...args: TArgs) => boolean

      • (...args: TArgs): boolean
      • Parameters

        • Rest ...args: TArgs

        Returns boolean

  • compose<TArgs, R1, R2, R3, R4, R5, R6, R7, TResult>(...func: [fnLast: (a: any) => TResult, ...func: ((a: any) => any)[], f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1]): (...args: TArgs) => TResult
  • compose<TArgs, R1, R2, R3, R4, R5, R6, R7>(f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1): (...args: TArgs) => R7
  • compose<TArgs, R1, R2, R3, R4, R5, R6, R7>(f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1): (...args: TArgs) => R7
  • compose<TArgs, R1, R2, R3, R4, R5, R6>(f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1): (...args: TArgs) => R6
  • compose<TArgs, R1, R2, R3, R4, R5>(f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1): (...args: TArgs) => R5
  • compose<TArgs, R1, R2, R3, R4>(f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1): (...args: TArgs) => R4
  • compose<TArgs, R1, R2, R3>(f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1): (...args: TArgs) => R3
  • compose<TArgs, R1, R2>(f2: (a: R1) => R2, f1: (...args: TArgs) => R1): (...args: TArgs) => R2
  • compose<TArgs, R1>(f1: (...args: TArgs) => R1): (...args: TArgs) => R1
  • Performs right-to-left function composition. The rightmost function may have any arity; the remaining functions must be unary.

    note

    The result of R.compose is not automatically curried.

    See also pipe.

    example
    const classyGreeting = (firstName: string, lastName: string) => "The name's " + lastName + ", " + firstName + " " + lastName
    const yellGreeting = R.compose(R.toUpper, classyGreeting);
    yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND"

    R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7

    Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    • R6

    • R7

    • TResult

    Parameters

    • Rest ...func: [fnLast: (a: any) => TResult, ...func: ((a: any) => any)[], f7: (a: R6) => R7, f6: (a: R5) => R6, f5: (a: R4) => R5, f4: (a: R3) => R4, f3: (a: R2) => R3, f2: (a: R1) => R2, f1: (...args: TArgs) => R1]

    Returns (...args: TArgs) => TResult

      • (...args: TArgs): TResult
      • Performs right-to-left function composition. The rightmost function may have any arity; the remaining functions must be unary.

        note

        The result of R.compose is not automatically curried.

        See also pipe.

        example
        const classyGreeting = (firstName: string, lastName: string) => "The name's " + lastName + ", " + firstName + " " + lastName
        const yellGreeting = R.compose(R.toUpper, classyGreeting);
        yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND"

        R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7

        Parameters

        • Rest ...args: TArgs

        Returns TResult

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    • R6

    • R7

    Parameters

    • f7: (a: R6) => R7
        • (a: R6): R7
        • Parameters

          • a: R6

          Returns R7

    • f6: (a: R5) => R6
        • (a: R5): R6
        • Parameters

          • a: R5

          Returns R6

    • f5: (a: R4) => R5
        • (a: R4): R5
        • Parameters

          • a: R4

          Returns R5

    • f4: (a: R3) => R4
        • (a: R3): R4
        • Parameters

          • a: R3

          Returns R4

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    Returns (...args: TArgs) => R7

      • (...args: TArgs): R7
      • Parameters

        • Rest ...args: TArgs

        Returns R7

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    • R6

    • R7

    Parameters

    • f7: (a: R6) => R7
        • (a: R6): R7
        • Parameters

          • a: R6

          Returns R7

    • f6: (a: R5) => R6
        • (a: R5): R6
        • Parameters

          • a: R5

          Returns R6

    • f5: (a: R4) => R5
        • (a: R4): R5
        • Parameters

          • a: R4

          Returns R5

    • f4: (a: R3) => R4
        • (a: R3): R4
        • Parameters

          • a: R3

          Returns R4

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    Returns (...args: TArgs) => R7

      • (...args: TArgs): R7
      • Parameters

        • Rest ...args: TArgs

        Returns R7

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    • R6

    Parameters

    • f6: (a: R5) => R6
        • (a: R5): R6
        • Parameters

          • a: R5

          Returns R6

    • f5: (a: R4) => R5
        • (a: R4): R5
        • Parameters

          • a: R4

          Returns R5

    • f4: (a: R3) => R4
        • (a: R3): R4
        • Parameters

          • a: R3

          Returns R4

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    Returns (...args: TArgs) => R6

      • (...args: TArgs): R6
      • Parameters

        • Rest ...args: TArgs

        Returns R6

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    Parameters

    • f5: (a: R4) => R5
        • (a: R4): R5
        • Parameters

          • a: R4

          Returns R5

    • f4: (a: R3) => R4
        • (a: R3): R4
        • Parameters

          • a: R3

          Returns R4

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    Returns (...args: TArgs) => R5

      • (...args: TArgs): R5
      • Parameters

        • Rest ...args: TArgs

        Returns R5

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    Parameters

    • f4: (a: R3) => R4
        • (a: R3): R4
        • Parameters

          • a: R3

          Returns R4

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    Returns (...args: TArgs) => R4

      • (...args: TArgs): R4
      • Parameters

        • Rest ...args: TArgs

        Returns R4

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    Parameters

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    Returns (...args: TArgs) => R3

      • (...args: TArgs): R3
      • Parameters

        • Rest ...args: TArgs

        Returns R3

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    Parameters

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    Returns (...args: TArgs) => R2

      • (...args: TArgs): R2
      • Parameters

        • Rest ...args: TArgs

        Returns R2

  • Type parameters

    • TArgs: any[]

    • R1

    Parameters

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    Returns (...args: TArgs) => R1

      • (...args: TArgs): R1
      • Parameters

        • Rest ...args: TArgs

        Returns R1

  • composeK<V0, T1>(fn0: (x0: V0) => T1[]): (x0: V0) => T1[]
  • composeK<V0, T1, T2>(fn1: (x: T1) => T2[], fn0: (x0: V0) => T1[]): (x0: V0) => T2[]
  • composeK<V0, T1, T2, T3>(fn2: (x: T2) => T3[], fn1: (x: T1) => T2[], fn0: (x: V0) => T1[]): (x: V0) => T3[]
  • composeK<V0, T1, T2, T3, T4>(fn3: (x: T3) => T4[], fn2: (x: T2) => T3[], fn1: (x: T1) => T2[], fn0: (x: V0) => T1[]): (x: V0) => T4[]
  • composeK<V0, T1, T2, T3, T4, T5>(fn4: (x: T4) => T5[], fn3: (x: T3) => T4[], fn2: (x: T2) => T3[], fn1: (x: T1) => T2[], fn0: (x: V0) => T1[]): (x: V0) => T5[]
  • composeK<V0, T1, T2, T3, T4, T5, T6>(fn5: (x: T5) => T6[], fn4: (x: T4) => T5[], fn3: (x: T3) => T4[], fn2: (x: T2) => T3[], fn1: (x: T1) => T2[], fn0: (x: V0) => T1[]): (x: V0) => T6[]
  • Returns the right-to-left Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. The typings only support arrays for now. All functions must be unary. R.composeK(h, g, f) is equivalent to R.compose(R.chain(h), R.chain(g), f).

    deprecated

    since 0.26 in favor of composeWith(chain)

    Type parameters

    • V0

    • T1

    Parameters

    • fn0: (x0: V0) => T1[]
        • (x0: V0): T1[]
        • Parameters

          • x0: V0

          Returns T1[]

    Returns (x0: V0) => T1[]

      • (x0: V0): T1[]
      • Returns the right-to-left Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. The typings only support arrays for now. All functions must be unary. R.composeK(h, g, f) is equivalent to R.compose(R.chain(h), R.chain(g), f).

        deprecated

        since 0.26 in favor of composeWith(chain)

        Parameters

        • x0: V0

        Returns T1[]

  • Type parameters

    • V0

    • T1

    • T2

    Parameters

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn0: (x0: V0) => T1[]
        • (x0: V0): T1[]
        • Parameters

          • x0: V0

          Returns T1[]

    Returns (x0: V0) => T2[]

      • (x0: V0): T2[]
      • Parameters

        • x0: V0

        Returns T2[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    Parameters

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    Returns (x: V0) => T3[]

      • (x: V0): T3[]
      • Parameters

        • x: V0

        Returns T3[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    Parameters

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    Returns (x: V0) => T4[]

      • (x: V0): T4[]
      • Parameters

        • x: V0

        Returns T4[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    • fn4: (x: T4) => T5[]
        • (x: T4): T5[]
        • Parameters

          • x: T4

          Returns T5[]

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    Returns (x: V0) => T5[]

      • (x: V0): T5[]
      • Parameters

        • x: V0

        Returns T5[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    • fn5: (x: T5) => T6[]
        • (x: T5): T6[]
        • Parameters

          • x: T5

          Returns T6[]

    • fn4: (x: T4) => T5[]
        • (x: T4): T5[]
        • Parameters

          • x: T4

          Returns T5[]

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    Returns (x: V0) => T6[]

      • (x: V0): T6[]
      • Parameters

        • x: V0

        Returns T6[]

  • composeP<V0, T1>(fn0: (x0: V0) => Promise<T1>): (x0: V0) => Promise<T1>
  • composeP<V0, T1, T2>(fn1: (x: T1) => Promise<T2>, fn0: (x0: V0) => Promise<T1>): (x0: V0) => Promise<T2>
  • composeP<V0, T1, T2, T3>(fn2: (x: T2) => Promise<T3>, fn1: (x: T1) => Promise<T2>, fn0: (x: V0) => Promise<T1>): (x: V0) => Promise<T3>
  • composeP<V0, T1, T2, T3, T4>(fn3: (x: T3) => Promise<T4>, fn2: (x: T2) => Promise<T3>, fn1: (x: T1) => Promise<T2>, fn0: (x: V0) => Promise<T1>): (x: V0) => Promise<T4>
  • composeP<V0, T1, T2, T3, T4, T5>(fn4: (x: T4) => Promise<T5>, fn3: (x: T3) => Promise<T4>, fn2: (x: T2) => Promise<T3>, fn1: (x: T1) => Promise<T2>, fn0: (x: V0) => Promise<T1>): (x: V0) => Promise<T5>
  • composeP<V0, T1, T2, T3, T4, T5, T6>(fn5: (x: T5) => Promise<T6>, fn4: (x: T4) => Promise<T5>, fn3: (x: T3) => Promise<T4>, fn2: (x: T2) => Promise<T3>, fn1: (x: T1) => Promise<T2>, fn0: (x: V0) => Promise<T1>): (x: V0) => Promise<T6>
  • Performs right-to-left composition of one or more Promise-returning functions. All functions must be unary.

    deprecated

    since 0.26 in favor of composeWith(then)

    Type parameters

    • V0

    • T1

    Parameters

    • fn0: (x0: V0) => Promise<T1>
        • (x0: V0): Promise<T1>
        • Parameters

          • x0: V0

          Returns Promise<T1>

    Returns (x0: V0) => Promise<T1>

      • (x0: V0): Promise<T1>
      • Performs right-to-left composition of one or more Promise-returning functions. All functions must be unary.

        deprecated

        since 0.26 in favor of composeWith(then)

        Parameters

        • x0: V0

        Returns Promise<T1>

  • Type parameters

    • V0

    • T1

    • T2

    Parameters

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn0: (x0: V0) => Promise<T1>
        • (x0: V0): Promise<T1>
        • Parameters

          • x0: V0

          Returns Promise<T1>

    Returns (x0: V0) => Promise<T2>

      • (x0: V0): Promise<T2>
      • Parameters

        • x0: V0

        Returns Promise<T2>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    Parameters

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    Returns (x: V0) => Promise<T3>

      • (x: V0): Promise<T3>
      • Parameters

        • x: V0

        Returns Promise<T3>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    Parameters

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    Returns (x: V0) => Promise<T4>

      • (x: V0): Promise<T4>
      • Parameters

        • x: V0

        Returns Promise<T4>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    • fn4: (x: T4) => Promise<T5>
        • (x: T4): Promise<T5>
        • Parameters

          • x: T4

          Returns Promise<T5>

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    Returns (x: V0) => Promise<T5>

      • (x: V0): Promise<T5>
      • Parameters

        • x: V0

        Returns Promise<T5>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    • fn5: (x: T5) => Promise<T6>
        • (x: T5): Promise<T6>
        • Parameters

          • x: T5

          Returns Promise<T6>

    • fn4: (x: T4) => Promise<T5>
        • (x: T4): Promise<T5>
        • Parameters

          • x: T4

          Returns Promise<T5>

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    Returns (x: V0) => Promise<T6>

      • (x: V0): Promise<T6>
      • Parameters

        • x: V0

        Returns Promise<T6>

  • Performs right-to-left function composition using transforming function. The last function may have any arity; the remaining functions must be unary.

    note

    The result of R.composeWith is not automatically curried. The transforming function is not used on the last argument.

    See also compose, pipeWith.

    example
    const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res));

    composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2

    Type parameters

    • TArgs: any[]

    • TResult

    Parameters

    Returns (...args: TArgs) => TResult

      • (...args: TArgs): TResult
      • Performs right-to-left function composition using transforming function. The last function may have any arity; the remaining functions must be unary.

        note

        The result of R.composeWith is not automatically curried. The transforming function is not used on the last argument.

        See also compose, pipeWith.

        example
        const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res));

        composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2

        Parameters

        • Rest ...args: TArgs

        Returns TResult

  • Parameters

    • transformer: (fn: AnyFunction, intermediatResult: any) => any

    Returns <TArgs, TResult>(fns: AtLeastOneFunctionsFlowFromRightToLeft<TArgs, TResult>) => (...args: TArgs) => TResult

  • concat(placeholder: Placeholder): (<L1, L2>(list1: L1, list2: L2) => [...L1, ...L2]) & (<S1, S2>(s1: S1, s2: S2) => `${S1}${S2}`)
  • concat<L2>(placeholder: Placeholder, list2: L2): <L1>(list1: L1) => [...L1, ...L2]
  • concat<S2>(placeholder: Placeholder, s2: S2): <S1>(s1: S1) => `${S1}${S2}`
  • concat<L1>(list1: L1): <L2>(list2: L2) => [...L1, ...L2]
  • concat<S1>(s1: S1): <S2>(s2: S2) => `${S1}${S2}`
  • concat<L1, L2>(list1: L1, list2: L2): [...L1, ...L2]
  • concat<S1, S2>(s1: S1, s2: S2): `${S1}${S2}`
  • concat(s1: string, s2: string): string
  • concat(s1: string): (s2: string) => string
  • Returns the result of concatenating the given lists or strings.

    note

    R.concat expects both arguments to be of the same type, unlike the native Array.prototype.concat method. It will throw an error if you concat an Array with a non-Array value.

    Dispatches to the concat method of the first argument, if present. Can also concatenate two members of a fantasy-land compatible semigroup.

    example
    R.concat('ABC', 'DEF'); // 'ABCDEF'
    R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
    R.concat([], []); //=> []

    Parameters

    Returns (<L1, L2>(list1: L1, list2: L2) => [...L1, ...L2]) & (<S1, S2>(s1: S1, s2: S2) => `${S1}${S2}`)

  • Type parameters

    • L2: any[]

    Parameters

    Returns <L1>(list1: L1) => [...L1, ...L2]

      • <L1>(list1: L1): [...L1, ...L2]
      • Type parameters

        • L1: any[]

        Parameters

        • list1: L1

        Returns [...L1, ...L2]

  • Type parameters

    • S2: string

    Parameters

    Returns <S1>(s1: S1) => `${S1}${S2}`

      • <S1>(s1: S1): `${S1}${S2}`
      • Type parameters

        • S1: string

        Parameters

        • s1: S1

        Returns `${S1}${S2}`

  • Type parameters

    • L1: any[]

    Parameters

    • list1: L1

    Returns <L2>(list2: L2) => [...L1, ...L2]

      • <L2>(list2: L2): [...L1, ...L2]
      • Type parameters

        • L2: any[]

        Parameters

        • list2: L2

        Returns [...L1, ...L2]

  • Type parameters

    • S1: string

    Parameters

    • s1: S1

    Returns <S2>(s2: S2) => `${S1}${S2}`

      • <S2>(s2: S2): `${S1}${S2}`
      • Type parameters

        • S2: string

        Parameters

        • s2: S2

        Returns `${S1}${S2}`

  • Type parameters

    • L1: any[]

    • L2: any[]

    Parameters

    • list1: L1
    • list2: L2

    Returns [...L1, ...L2]

  • Type parameters

    • S1: string

    • S2: string

    Parameters

    • s1: S1
    • s2: S2

    Returns `${S1}${S2}`

  • Parameters

    • s1: string
    • s2: string

    Returns string

  • Parameters

    • s1: string

    Returns (s2: string) => string

      • (s2: string): string
      • Parameters

        • s2: string

        Returns string

  • Returns a function, fn, which encapsulates if/else, if/else, ... logic. R.cond takes a list of [predicate, transformer] pairs. All of the arguments to fn are applied to each of the predicates in turn until one returns a "truthy" value, at which point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates matches, fn returns undefined.

    note

    This is not a direct substitute for a switch statement. Remember that both elements of every pair passed to cond are functions, and cond returns a function.

    note

    When using this function with a typeguard as predicate, all predicates in all pairs must be typeguards.

    See also ifElse, unless, when.

    example
    const fn = R.cond([
    [R.equals(0), R.always('water freezes at 0°C')],
    [R.equals(100), R.always('water boils at 100°C')],
    [R.T, temp => 'nothing special happens at ' + temp + '°C']
    ]);
    fn(0); //=> 'water freezes at 0°C'
    fn(50); //=> 'nothing special happens at 50°C'
    fn(100); //=> 'water boils at 100°C'

    Type parameters

    • T

    • TF1

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Returns a function, fn, which encapsulates if/else, if/else, ... logic. R.cond takes a list of [predicate, transformer] pairs. All of the arguments to fn are applied to each of the predicates in turn until one returns a "truthy" value, at which point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates matches, fn returns undefined.

        note

        This is not a direct substitute for a switch statement. Remember that both elements of every pair passed to cond are functions, and cond returns a function.

        note

        When using this function with a typeguard as predicate, all predicates in all pairs must be typeguards.

        See also ifElse, unless, when.

        example
        const fn = R.cond([
        [R.equals(0), R.always('water freezes at 0°C')],
        [R.equals(100), R.always('water boils at 100°C')],
        [R.T, temp => 'nothing special happens at ' + temp + '°C']
        ]);
        fn(0); //=> 'water freezes at 0°C'
        fn(50); //=> 'nothing special happens at 50°C'
        fn(100); //=> 'water boils at 100°C'

        Parameters

        • value: T

        Returns R

  • Type parameters

    • T

    • TF1

    • TF2

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Parameters

        • value: T

        Returns R

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Parameters

        • value: T

        Returns R

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Parameters

        • value: T

        Returns R

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Parameters

        • value: T

        Returns R

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    • TF6

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Parameters

        • value: T

        Returns R

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    • TF6

    • TF7

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Parameters

        • value: T

        Returns R

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    • TF6

    • TF7

    • TF8

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Parameters

        • value: T

        Returns R

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    • TF6

    • TF7

    • TF8

    • TF9

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Parameters

        • value: T

        Returns R

  • Type parameters

    • T

    • TF1

    • TF2

    • TF3

    • TF4

    • TF5

    • TF6

    • TF7

    • TF8

    • TF9

    • TF10

    • R

    Parameters

    Returns (value: T) => R

      • (value: T): R
      • Parameters

        • value: T

        Returns R

  • Type parameters

    • T: any[]

    • R

    Parameters

    Returns (...args: T) => R

      • (...args: T): R
      • Parameters

        • Rest ...args: T

        Returns R

  • construct<A, T>(constructor: (new (...args: A) => T) | ((...args: A) => T)): _.F.Curry<(...args: A) => T>
  • Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.

    See also invoker.

    example
    // Constructor function
    class Animal {
    constructor(public kind: string) {}

    sighting() {
    return "It's a " + this.kind + "!";
    }
    }

    const AnimalConstructor = R.construct(Animal)

    // Notice we no longer need the 'new' keyword:
    AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}};

    const animalTypes = ["Lion", "Tiger", "Bear"];
    const animalSighting = R.invoker(0, 'sighting');
    const sightNewAnimal = R.compose(animalSighting, AnimalConstructor);
    R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"]

    Type parameters

    • A: any[]

    • T

    Parameters

    • constructor: (new (...args: A) => T) | ((...args: A) => T)

    Returns _.F.Curry<(...args: A) => T>

  • constructN<A, T, N>(n: N, constructor: (new (...args: A) => T) | ((...args: A) => T)): _.F.Curry<(...args: mergeArrWithLeft<Tuple<any, N>, A>) => T>
  • Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. The arity of the function returned is specified to allow using variadic constructor functions.

    Type parameters

    • A: any[]

    • T

    • N: number

    Parameters

    • n: N
    • constructor: (new (...args: A) => T) | ((...args: A) => T)

    Returns _.F.Curry<(...args: mergeArrWithLeft<Tuple<any, N>, A>) => T>

  • contains(__: Placeholder, list: string): (a: string) => boolean
  • contains<T>(__: Placeholder, list: readonly T[]): (a: T) => boolean
  • contains(__: Placeholder): (list: string, a: string) => boolean
  • contains<T>(__: Placeholder): (list: readonly T[], a: T) => boolean
  • contains(a: string, list: string): boolean
  • contains<T>(a: T, list: readonly T[]): boolean
  • contains(a: string): (list: string) => boolean
  • contains<T>(a: T): (list: readonly T[]) => boolean
  • Returns true if the specified item is somewhere in the list, false otherwise. Equivalent to indexOf(a)(list) > -1. Uses strict (===) equality checking.

    deprecated

    since 0.26 in favor of includes

    Parameters

    Returns (a: string) => boolean

      • (a: string): boolean
      • Returns true if the specified item is somewhere in the list, false otherwise. Equivalent to indexOf(a)(list) > -1. Uses strict (===) equality checking.

        deprecated

        since 0.26 in favor of includes

        Parameters

        • a: string

        Returns boolean

  • Type parameters

    • T

    Parameters

    Returns (a: T) => boolean

      • (a: T): boolean
      • Parameters

        • a: T

        Returns boolean

  • Parameters

    Returns (list: string, a: string) => boolean

      • (list: string, a: string): boolean
      • Parameters

        • list: string
        • a: string

        Returns boolean

  • Type parameters

    • T

    Parameters

    Returns (list: readonly T[], a: T) => boolean

      • (list: readonly T[], a: T): boolean
      • Parameters

        • list: readonly T[]
        • a: T

        Returns boolean

  • Parameters

    • a: string
    • list: string

    Returns boolean

  • Type parameters

    • T

    Parameters

    • a: T
    • list: readonly T[]

    Returns boolean

  • Parameters

    • a: string

    Returns (list: string) => boolean

      • (list: string): boolean
      • Parameters

        • list: string

        Returns boolean

  • Type parameters

    • T

    Parameters

    • a: T

    Returns (list: readonly T[]) => boolean

      • (list: readonly T[]): boolean
      • Parameters

        • list: readonly T[]

        Returns boolean

  • converge<TResult, FunctionsList, _Fns>(converging: (...args: ReturnTypesOfFns<FunctionsList>) => TResult, branches: FunctionsList): _.F.Curry<(...args: LargestArgumentsList<FunctionsList>) => TResult>
  • converge<CArgs, TResult, FunctionsList, _Fns>(converging: (...args: CArgs) => TResult, branches: FunctionsList): _.F.Curry<(...args: LargestArgumentsList<FunctionsList>) => TResult>
  • Accepts a converging function and a list of branching functions and returns a new function. When invoked, this new function is applied to some arguments, each branching function is applied to those same arguments. The results of each branching function are passed as arguments to the converging function to produce the return value.

    See also useWith.

    Type parameters

    • TResult

    • FunctionsList: readonly Fn[]

    • _Fns: readonly Fn[] = FunctionsList

    Parameters

    Returns _.F.Curry<(...args: LargestArgumentsList<FunctionsList>) => TResult>

  • Type parameters

    • CArgs: readonly any[]

    • TResult

    • FunctionsList: readonly [{ [ Index in string | number | symbol]: (...args: readonly any[]) => CArgs[Index] }, FunctionsList]

    • _Fns: readonly Fn[] = FunctionsList

    Parameters

    • converging: (...args: CArgs) => TResult
        • (...args: CArgs): TResult
        • Parameters

          • Rest ...args: CArgs

          Returns TResult

    • branches: FunctionsList

    Returns _.F.Curry<(...args: LargestArgumentsList<FunctionsList>) => TResult>

  • count<T>(fn: (a: T) => boolean, list: readonly T[]): number
  • count<T>(fn: (a: T) => boolean): (list: readonly T[]) => number
  • Returns the number of items in a given list matching the predicate f.

    example
    const even = (x: number) => x % 2 == 0;

    R.count(even, [1, 2, 3, 4, 5]); // => 2
    R.map(R.count(even), [[1, 1, 1], [2, 3, 4, 5], [6]]); // => [0, 2, 1]

    Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns number

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns (list: readonly T[]) => number

      • (list: readonly T[]): number
      • Parameters

        • list: readonly T[]

        Returns number

  • countBy<T>(fn: (a: T) => string | number, list: readonly T[]): {}
  • countBy<T>(fn: (a: T) => string | number): (list: readonly T[]) => {}
  • Counts the elements of a list according to how many match each value of a key generated by the supplied function. Returns an object mapping the keys produced by fn to the number of occurrences in the list. Note that all keys are coerced to strings because of how JavaScript objects work.

    Acts as a transducer if a transformer is given in list position.

    See also transduce.

    example
    const numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2];
    R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1}

    const letters = ['a', 'b', 'A', 'a', 'B', 'c'];
    R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1}

    Type parameters

    • T

    Parameters

    • fn: (a: T) => string | number
        • (a: T): string | number
        • Parameters

          • a: T

          Returns string | number

    • list: readonly T[]

    Returns {}

    • [index: string]: number
  • Type parameters

    • T

    Parameters

    • fn: (a: T) => string | number
        • (a: T): string | number
        • Parameters

          • a: T

          Returns string | number

    Returns (list: readonly T[]) => {}

      • (list: readonly T[]): {}
      • Parameters

        • list: readonly T[]

        Returns {}

        • [index: string]: number
  • curry<F>(f: F): _.F.Curry<F>
  • Returns a curried equivalent of the provided function.

    See also curryN, partial.

    The curried function has two unusual capabilities.

    First, its arguments needn't be provided one at a time. If f is a ternary function and g is R.curry(f), the following are equivalent:

    • g(1)(2)(3)
    • g(1)(2, 3)
    • g(1, 2)(3)
    • g(1, 2, 3)

    Secondly, the special placeholder value R.__ may be used to specify "gaps", allowing partial application of any combination of arguments, regardless of their positions. If g is as above and _ is R.__, the following are equivalent:

    • g(1, 2, 3)
    • g(_, 2, 3)(1)
    • g(_, _, 3)(1)(2)
    • g(_, _, 3)(1, 2)
    • g(_, 2)(1)(3)
    • g(_, 2)(1, 3)
    • g(_, 2)(_, 3)(1)
    example
    const addFourNumbers = (a: number, b: number, c: number, d: number) => a + b + c + d;

    const curriedAddFourNumbers = R.curry(addFourNumbers);
    const f = curriedAddFourNumbers(1, 2);
    const g = f(3);
    g(4); //=> 10

    Type parameters

    Parameters

    • f: F

    Returns _.F.Curry<F>

  • curryN<N, F>(length: N, fn: F): _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>
  • curryN<N>(length: N): <F>(fn: F) => _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>
  • Returns a curried equivalent of the provided function, with the specified arity.

    See also curry.

    The curried function has two unusual capabilities.

    First, its arguments needn't be provided one at a time. If f is a ternary function and g is R.curry(f), the following are equivalent:

    • g(1)(2)(3)
    • g(1)(2, 3)
    • g(1, 2)(3)
    • g(1, 2, 3)

    Secondly, the special placeholder value R.__ may be used to specify "gaps", allowing partial application of any combination of arguments, regardless of their positions. If g is as above and _ is R.__, the following are equivalent:

    • g(1, 2, 3)
    • g(_, 2, 3)(1)
    • g(_, _, 3)(1)(2)
    • g(_, _, 3)(1, 2)
    • g(_, 2)(1)(3)
    • g(_, 2)(1, 3)
    • g(_, 2)(_, 3)(1)
    example
    const sumArgs = (...args: number[]) => R.sum(args);

    const curriedAddFourNumbers = R.curryN(4, sumArgs);
    const f = curriedAddFourNumbers(1, 2);
    const g = f(3);
    g(4); //=> 10

    Type parameters

    Parameters

    • length: N
    • fn: F

    Returns _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>

  • Type parameters

    • N: number

    Parameters

    • length: N

    Returns <F>(fn: F) => _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>

      • <F>(fn: F): _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>
      • Type parameters

        Parameters

        • fn: F

        Returns _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>

  • dec(n: number): number
  • Decrements its argument.

    See also inc.

    example
    R.dec(42); //=> 41
    

    Parameters

    • n: number

    Returns number

  • defaultTo<T, U>(a: T, b: undefined | null | U): T | U
  • defaultTo<T>(a: T): <U>(b: U | null | undefined) => T | U
  • Returns the second argument if it is not null, undefined or NaN; otherwise the first argument is returned.

    example
    const defaultTo42 = R.defaultTo(42);

    defaultTo42(null); //=> 42
    defaultTo42(undefined); //=> 42
    defaultTo42(false); //=> false
    defaultTo42('Ramda'); //=> 'Ramda'
    // parseInt('string') results in NaN
    defaultTo42(parseInt('string')); //=> 42

    Type parameters

    • T

    • U

    Parameters

    • a: T
    • b: undefined | null | U

    Returns T | U

  • Type parameters

    • T

    Parameters

    • a: T

    Returns <U>(b: U | null | undefined) => T | U

      • <U>(b: U | null | undefined): T | U
      • Type parameters

        • U

        Parameters

        • b: U | null | undefined

        Returns T | U

  • descend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering
  • descend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering
  • Makes a descending comparator function out of a function that returns a value that can be compared with < and >.

    See also ascend.

    example
    type Person = { name: string; age: number; };

    const byAge = R.descend<Person>(R.prop('age'));
    const people = [
    { name: 'Emma', age: 70 },
    { name: 'Peter', age: 78 },
    { name: 'Mikhail', age: 62 },
    ];
    const peopleByOldestFirst = R.sort(byAge, people);
    //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }]

    Type parameters

    • T

    Parameters

    • fn: (obj: T) => Ord
        • Parameters

          • obj: T

          Returns Ord

    • a: T
    • b: T

    Returns Ordering

  • Type parameters

    • T

    Parameters

    • fn: (obj: T) => Ord
        • Parameters

          • obj: T

          Returns Ord

    Returns (a: T, b: T) => Ordering

  • difference<T>(list1: readonly T[], list2: readonly T[]): T[]
  • difference<T>(list1: readonly T[]): (list2: readonly T[]) => T[]
  • Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. Objects and Arrays are compared in terms of value equality, not reference equality.

    example
    R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2]
    R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5]
    R.difference<{ a: number; } | { b: number; } | { c: number; }>([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}]

    Type parameters

    • T

    Parameters

    • list1: readonly T[]
    • list2: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • list1: readonly T[]

    Returns (list2: readonly T[]) => T[]

      • (list2: readonly T[]): T[]
      • Parameters

        • list2: readonly T[]

        Returns T[]

  • differenceWith<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[], list2: readonly T2[]): T1[]
  • differenceWith<T1, T2>(pred: (a: T1, b: T2) => boolean): (list1: readonly T1[], list2: readonly T2[]) => T1[]
  • differenceWith<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[]): (list2: readonly T2[]) => T1[]
  • Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. Duplication is determined according to the value returned by applying the supplied predicate to two list elements.

    example
    const cmp = (x: { a: number; }, y: { a: number; }) => x.a === y.a;
    const l1 = [{a: 1}, {a: 2}, {a: 3}];
    const l2 = [{a: 3}, {a: 4}];
    R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}]

    Type parameters

    • T1

    • T2

    Parameters

    • pred: (a: T1, b: T2) => boolean
        • (a: T1, b: T2): boolean
        • Parameters

          • a: T1
          • b: T2

          Returns boolean

    • list1: readonly T1[]
    • list2: readonly T2[]

    Returns T1[]

  • Type parameters

    • T1

    • T2

    Parameters

    • pred: (a: T1, b: T2) => boolean
        • (a: T1, b: T2): boolean
        • Parameters

          • a: T1
          • b: T2

          Returns boolean

    Returns (list1: readonly T1[], list2: readonly T2[]) => T1[]

      • (list1: readonly T1[], list2: readonly T2[]): T1[]
      • Parameters

        • list1: readonly T1[]
        • list2: readonly T2[]

        Returns T1[]

  • Type parameters

    • T1

    • T2

    Parameters

    • pred: (a: T1, b: T2) => boolean
        • (a: T1, b: T2): boolean
        • Parameters

          • a: T1
          • b: T2

          Returns boolean

    • list1: readonly T1[]

    Returns (list2: readonly T2[]) => T1[]

      • (list2: readonly T2[]): T1[]
      • Parameters

        • list2: readonly T2[]

        Returns T1[]

  • dissoc<T, K>(prop: K, obj: T): Omit<T, K>
  • dissoc<K>(prop: K): <T>(obj: T) => Omit<T, K>
  • Returns a new object that does not contain the given property.

    See also assoc, omit.

    example
    R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3}
    

    Type parameters

    • T: object

    • K: string | number | symbol

    Parameters

    • prop: K
    • obj: T

    Returns Omit<T, K>

  • Type parameters

    • K: string | number

    Parameters

    • prop: K

    Returns <T>(obj: T) => Omit<T, K>

      • <T>(obj: T): Omit<T, K>
      • Type parameters

        • T: object

        Parameters

        • obj: T

        Returns Omit<T, K>

  • dissocPath<T>(path: Path, obj: any): T
  • dissocPath<T>(path: Path): (obj: any) => T
  • Makes a shallow clone of an object, omitting the property at the given path.

    note

    This copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

    example
    R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}}
    

    Type parameters

    • T

    Parameters

    Returns T

  • Type parameters

    • T

    Parameters

    Returns (obj: any) => T

      • (obj: any): T
      • Parameters

        • obj: any

        Returns T

  • divide(__: Placeholder, b: number): (a: number) => number
  • divide(__: Placeholder): (b: number, a: number) => number
  • divide(a: number, b: number): number
  • divide(a: number): (b: number) => number
  • Divides two numbers. Equivalent to a / b but curried.

    See also multiply.

    example
    R.divide(71, 100); //=> 0.71

    const half = R.divide(R.__, 2);
    half(42); //=> 21

    const reciprocal = R.divide(1);
    reciprocal(4); //=> 0.25

    Parameters

    Returns (a: number) => number

      • (a: number): number
      • Divides two numbers. Equivalent to a / b but curried.

        See also multiply.

        example
        R.divide(71, 100); //=> 0.71

        const half = R.divide(R.__, 2);
        half(42); //=> 21

        const reciprocal = R.divide(1);
        reciprocal(4); //=> 0.25

        Parameters

        • a: number

        Returns number

  • Parameters

    Returns (b: number, a: number) => number

      • (b: number, a: number): number
      • Parameters

        • b: number
        • a: number

        Returns number

  • Parameters

    • a: number
    • b: number

    Returns number

  • Parameters

    • a: number

    Returns (b: number) => number

      • (b: number): number
      • Parameters

        • b: number

        Returns number

  • drop<T>(n: number, xs: readonly T[]): T[]
  • drop(n: number, xs: string): string
  • drop<T>(n: number): { (xs: string): string; (xs: readonly T[]): T[] }
  • Returns all but the first n elements of the given list, string, or transducer/transformer.

    Dispatches to the drop method of the second argument, if present.

    See also take, transduce, dropLast, dropWhile.

    example
    R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
    R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz']
    R.drop(3, ['foo', 'bar', 'baz']); //=> []
    R.drop(4, ['foo', 'bar', 'baz']); //=> []
    R.drop(3, 'ramda'); //=> 'da'

    Type parameters

    • T

    Parameters

    • n: number
    • xs: readonly T[]

    Returns T[]

  • Parameters

    • n: number
    • xs: string

    Returns string

  • Type parameters

    • T

    Parameters

    • n: number

    Returns { (xs: string): string; (xs: readonly T[]): T[] }

      • (xs: string): string
      • (xs: readonly T[]): T[]
      • Parameters

        • xs: string

        Returns string

      • Parameters

        • xs: readonly T[]

        Returns T[]

  • dropLast<T>(n: number, xs: readonly T[]): T[]
  • dropLast(n: number, xs: string): string
  • dropLast<T>(n: number): { (xs: readonly T[]): T[]; (xs: string): string }
  • Returns a list containing all but the last n elements of the given list.

    Acts as a transducer if a transformer is given in list position.

    See also takeLast, drop, dropWhile, dropLastWhile, transduce.

    example
    R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
    R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo']
    R.dropLast(3, ['foo', 'bar', 'baz']); //=> []
    R.dropLast(4, ['foo', 'bar', 'baz']); //=> []
    R.dropLast(3, 'ramda'); //=> 'ra'

    Type parameters

    • T

    Parameters

    • n: number
    • xs: readonly T[]

    Returns T[]

  • Parameters

    • n: number
    • xs: string

    Returns string

  • Type parameters

    • T

    Parameters

    • n: number

    Returns { (xs: readonly T[]): T[]; (xs: string): string }

      • (xs: readonly T[]): T[]
      • (xs: string): string
      • Parameters

        • xs: readonly T[]

        Returns T[]

      • Parameters

        • xs: string

        Returns string

  • dropLastWhile<T>(fn: (a: T) => boolean, list: readonly T[]): T[]
  • dropLastWhile<T>(fn: (a: T) => boolean): (list: readonly T[]) => T[]
  • Returns a new list excluding all the tailing elements of a given list which satisfy the supplied predicate function. It passes each value from the right to the supplied predicate function, skipping elements until the predicate function returns a falsy value.

    Acts as a transducer if a transformer is given in list position.

    See also takeLastWhile, addIndex, drop, dropWhile, transduce.

    example
    const lteThree = (x: number) => x <= 3;

    R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4]

    R.dropLastWhile(x => x !== 'd', 'Ramda'); //=> 'Ramd'

    Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • dropRepeats<T>(list: readonly T[]): T[]
  • Returns a new list without any consecutively repeating elements. R.equals is used to determine equality.

    Acts as a transducer if a transformer is given in list position.

    See also transduce.

    example
    R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2]
    

    Type parameters

    • T

    Parameters

    • list: readonly T[]

    Returns T[]

  • dropRepeatsWith<T>(predicate: (left: T, right: T) => boolean, list: readonly T[]): T[]
  • dropRepeatsWith<T>(predicate: (left: T, right: T) => boolean): (list: readonly T[]) => T[]
  • Returns a new list without any consecutively repeating elements. Equality is determined by applying the supplied predicate to each pair of consecutive elements. The first element in a series of equal elements will be preserved.

    Acts as a transducer if a transformer is given in list position.

    See also transduce.

    example
    const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3];
    R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3]

    Type parameters

    • T

    Parameters

    • predicate: (left: T, right: T) => boolean
        • (left: T, right: T): boolean
        • Parameters

          • left: T
          • right: T

          Returns boolean

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • predicate: (left: T, right: T) => boolean
        • (left: T, right: T): boolean
        • Parameters

          • left: T
          • right: T

          Returns boolean

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • dropWhile<T>(fn: (a: T) => boolean, list: readonly T[]): T[]
  • dropWhile<T>(fn: (a: T) => boolean): (list: readonly T[]) => T[]
  • Returns a new list excluding the leading elements of a given list which satisfy the supplied predicate function. It passes each value to the supplied predicate function, skipping elements while the predicate function returns a truthy value.

    Dispatches to the dropWhile method of the second argument, if present.

    Acts as a transducer if a transformer is given in list position.

    See also takeWhile, addIndex, transduce.

    example
    const lteTwo = (x: number) => x <= 2;

    R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1]

    R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da'

    Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • either<T>(pred1: T, pred2: T): T
  • either<T>(pred1: T): (pred2: T) => T
  • A function wrapping calls to the two functions in an || operation, returning the result of the first function if it is truthy and the result of the second function otherwise.

    note

    This is short-circuited, meaning that the second function will not be invoked if the first returns a truthy value.

    See also both, or.

    example
    const gt10 = (x: number) => x > 10;
    const even = (x: number) => x % 2 === 0;
    const f = R.either(gt10, even);
    f(101); //=> true
    f(8); //=> true

    Type parameters

    Parameters

    • pred1: T
    • pred2: T

    Returns T

  • Type parameters

    Parameters

    • pred1: T

    Returns (pred2: T) => T

      • (pred2: T): T
      • Parameters

        • pred2: T

        Returns T

  • empty<T>(x: T): T
  • Returns the empty value of its argument's type. Ramda defines the empty value of Array ([]), Object ({}), string (''), TypedArray (Uint8Array [], Float32Array [], etc) and arguments.

    Other types are supported if they define <Type>.empty, <Type>.prototype.empty or implement the FantasyLand Monoid spec.

    Dispatches to the empty method of the first argument, if present.

    example
    R.empty([1, 2, 3]);                  //=> []
    R.empty('unicorns'); //=> ''
    R.empty({x: 1, y: 2}); //=> {}
    R.empty(Uint8Array.from([1, 2, 3])); //=> Uint8Array []

    Type parameters

    • T

    Parameters

    • x: T

    Returns T

  • endsWith(substr: string, str: string): boolean
  • endsWith(substr: string): (str: string) => boolean
  • endsWith<T>(subList: readonly T[], list: readonly T[]): boolean
  • endsWith<T>(subList: readonly T[]): (list: readonly T[]) => boolean
  • Checks if a list ends with the provided sublist.

    Similarly, checks if a string ends with the provided substring.

    See also startsWith.

    example
    R.endsWith('c', 'abc')                //=> true
    R.endsWith('b', 'abc') //=> false
    R.endsWith(['c'], ['a', 'b', 'c']) //=> true
    R.endsWith(['b'], ['a', 'b', 'c']) //=> false

    Parameters

    • substr: string
    • str: string

    Returns boolean

  • Parameters

    • substr: string

    Returns (str: string) => boolean

      • (str: string): boolean
      • Parameters

        • str: string

        Returns boolean

  • Type parameters

    • T

    Parameters

    • subList: readonly T[]
    • list: readonly T[]

    Returns boolean

  • Type parameters

    • T

    Parameters

    • subList: readonly T[]

    Returns (list: readonly T[]) => boolean

      • (list: readonly T[]): boolean
      • Parameters

        • list: readonly T[]

        Returns boolean

  • eqBy<T>(fn: (a: T) => unknown, a: T, b: T): boolean
  • eqBy<T>(fn: (a: T) => unknown, a: T): (b: T) => boolean
  • eqBy<T>(fn: (a: T) => unknown): { (a: T, b: T): boolean; (a: T): (b: T) => boolean }
  • Takes a function and two values in its domain and returns true if the values map to the same value in the codomain; false otherwise.

    example
    R.eqBy(Math.abs, 5, -5); //=> true
    

    Type parameters

    • T

    Parameters

    • fn: (a: T) => unknown
        • (a: T): unknown
        • Parameters

          • a: T

          Returns unknown

    • a: T
    • b: T

    Returns boolean

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => unknown
        • (a: T): unknown
        • Parameters

          • a: T

          Returns unknown

    • a: T

    Returns (b: T) => boolean

      • (b: T): boolean
      • Parameters

        • b: T

        Returns boolean

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => unknown
        • (a: T): unknown
        • Parameters

          • a: T

          Returns unknown

    Returns { (a: T, b: T): boolean; (a: T): (b: T) => boolean }

      • (a: T, b: T): boolean
      • (a: T): (b: T) => boolean
      • Parameters

        • a: T
        • b: T

        Returns boolean

      • Parameters

        • a: T

        Returns (b: T) => boolean

          • (b: T): boolean
          • Parameters

            • b: T

            Returns boolean

  • eqProps<T, U>(prop: string, obj1: T, obj2: U): boolean
  • eqProps<P>(prop: P): <T, U>(obj1: Record<P, T>, obj2: Record<P, U>) => boolean
  • eqProps<T>(prop: string, obj1: T): <U>(obj2: U) => boolean
  • Reports whether two objects have the same value, in R.equals terms, for the specified property. Useful as a curried predicate.

    example
    const o1 = { a: 1, b: 2, c: 3, d: 4 };
    const o2 = { a: 10, b: 20, c: 3, d: 40 };
    R.eqProps('a', o1, o2); //=> false
    R.eqProps('c', o1, o2); //=> true

    Type parameters

    • T

    • U

    Parameters

    • prop: string
    • obj1: T
    • obj2: U

    Returns boolean

  • Type parameters

    • P: string

    Parameters

    • prop: P

    Returns <T, U>(obj1: Record<P, T>, obj2: Record<P, U>) => boolean

      • <T, U>(obj1: Record<P, T>, obj2: Record<P, U>): boolean
      • Type parameters

        • T

        • U

        Parameters

        • obj1: Record<P, T>
        • obj2: Record<P, U>

        Returns boolean

  • Type parameters

    • T

    Parameters

    • prop: string
    • obj1: T

    Returns <U>(obj2: U) => boolean

      • <U>(obj2: U): boolean
      • Type parameters

        • U

        Parameters

        • obj2: U

        Returns boolean

  • equals<T>(__: Placeholder, b: T): (a: T) => boolean
  • equals<T>(a: T, b: T): boolean
  • equals<T>(a: T): (b: T) => boolean
  • Returns true if its arguments are equivalent, false otherwise. Handles cyclical data structures.

    Dispatches symmetrically to the equals methods of both arguments, if present.

    example
    R.equals(1, 1); //=> true
    R.equals([1, 2, 3], [1, 2, 3]); //=> true

    type Recursive = { v: Recursive; };

    const a: Recursive = {} as Recursive; a.v = a;
    const b: Recursive = {} as Recursive; b.v = b;
    R.equals(a, b); //=> true

    Type parameters

    • T

    Parameters

    Returns (a: T) => boolean

      • (a: T): boolean
      • Returns true if its arguments are equivalent, false otherwise. Handles cyclical data structures.

        Dispatches symmetrically to the equals methods of both arguments, if present.

        example
        R.equals(1, 1); //=> true
        R.equals([1, 2, 3], [1, 2, 3]); //=> true

        type Recursive = { v: Recursive; };

        const a: Recursive = {} as Recursive; a.v = a;
        const b: Recursive = {} as Recursive; b.v = b;
        R.equals(a, b); //=> true

        Parameters

        • a: T

        Returns boolean

  • Type parameters

    • T

    Parameters

    • a: T
    • b: T

    Returns boolean

  • Type parameters

    • T

    Parameters

    • a: T

    Returns (b: T) => boolean

      • (b: T): boolean
      • Parameters

        • b: T

        Returns boolean

  • evolve<E, V>(transformations: E, obj: V): Evolve<V, E>
  • evolve<E>(transformations: E): <V>(obj: V) => Evolve<V, E>
  • Creates a new object by evolving a shallow copy of the object, according to the functions in transformations. All non-primitive properties are copied by reference.

    A function in transformations will not be invoked if its corresponding key does not exist in the evolved object.

    example
    const tomato = {firstName: '  Tomato ', data: {elapsed: 100, remaining: 1400}, id:123};
    const transformations = {
    firstName: R.trim,
    lastName: R.trim, // Will not get invoked.
    data: {elapsed: R.add(1), remaining: R.add(-1)}
    };
    R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123}

    Type parameters

    Parameters

    • transformations: E
    • obj: V

    Returns Evolve<V, E>

  • Type parameters

    Parameters

    • transformations: E

    Returns <V>(obj: V) => Evolve<V, E>

  • filter<A, P>(pred: (val: A) => val is P): { <B>(list: readonly B[]): P[]; <B>(dict: Dictionary<B>): Dictionary<P> }
  • filter<T>(pred: (value: T) => boolean): <P, C>(collection: C) => C
  • filter<T, P>(pred: (val: T) => val is P, list: readonly T[]): P[]
  • filter<T, P>(pred: (val: T) => val is P, dict: Dictionary<T>): Dictionary<P>
  • filter<T, C>(pred: (value: T) => boolean, collection: C): C
  • Takes a predicate and a Filterable, and returns a new Filterable of the same type containing the members of the given Filterable which satisfy the given predicate. Filterable objects include plain objects or any object that has a filter method such as Array.

    Dispatches to the filter method of the second argument, if present.

    Acts as a transducer if a transformer is given in list position.

    See also reject, transduce, addIndex.

    example
    const isEven = (n: number) => n % 2 === 0;

    R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4]

    R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}

    Type parameters

    • A

    • P

    Parameters

    • pred: (val: A) => val is P
        • (val: A): val is P
        • Parameters

          • val: A

          Returns val is P

    Returns { <B>(list: readonly B[]): P[]; <B>(dict: Dictionary<B>): Dictionary<P> }

  • Type parameters

    • T

    Parameters

    • pred: (value: T) => boolean
        • (value: T): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns <P, C>(collection: C) => C

      • <P, C>(collection: C): C
      • Type parameters

        Parameters

        • collection: C

        Returns C

  • Type parameters

    • T

    • P

    Parameters

    • pred: (val: T) => val is P
        • (val: T): val is P
        • Parameters

          • val: T

          Returns val is P

    • list: readonly T[]

    Returns P[]

  • Type parameters

    • T

    • P

    Parameters

    • pred: (val: T) => val is P
        • (val: T): val is P
        • Parameters

          • val: T

          Returns val is P

    • dict: Dictionary<T>

    Returns Dictionary<P>

  • Type parameters

    Parameters

    • pred: (value: T) => boolean
        • (value: T): boolean
        • Parameters

          • value: T

          Returns boolean

    • collection: C

    Returns C

  • find<T, P>(pred: (val: T) => val is P, list: readonly T[]): P | undefined
  • find<T>(pred: (val: T) => boolean, list: readonly T[]): T | undefined
  • find<T, P>(pred: (val: T) => val is P): (list: readonly T[]) => P | undefined
  • find<T>(pred: (val: T) => boolean): (list: readonly T[]) => T | undefined
  • Returns the first element of the list which matches the predicate, or undefined if no element matches.

    Dispatches to the find method of the second argument, if present.

    Acts as a transducer if a transformer is given in list position.

    See also transduce.

    example
    const xs = [{a: 1}, {a: 2}, {a: 3}];
    R.find(R.propEq('a', 2))(xs); //=> {a: 2}
    R.find(R.propEq('a', 4))(xs); //=> undefined

    Type parameters

    • T

    • P

    Parameters

    • pred: (val: T) => val is P
        • (val: T): val is P
        • Parameters

          • val: T

          Returns val is P

    • list: readonly T[]

    Returns P | undefined

  • Type parameters

    • T

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    • list: readonly T[]

    Returns T | undefined

  • Type parameters

    • T

    • P

    Parameters

    • pred: (val: T) => val is P
        • (val: T): val is P
        • Parameters

          • val: T

          Returns val is P

    Returns (list: readonly T[]) => P | undefined

      • (list: readonly T[]): P | undefined
      • Parameters

        • list: readonly T[]

        Returns P | undefined

  • Type parameters

    • T

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    Returns (list: readonly T[]) => T | undefined

      • (list: readonly T[]): T | undefined
      • Parameters

        • list: readonly T[]

        Returns T | undefined

  • findIndex<T>(fn: (a: T) => boolean, list: readonly T[]): number
  • findIndex<T>(fn: (a: T) => boolean): (list: readonly T[]) => number
  • Returns the index of the first element of the list which matches the predicate, or -1 if no element matches.

    Acts as a transducer if a transformer is given in list position.

    See also indexOf, transduce.

    example
    const xs = [{a: 1}, {a: 2}, {a: 3}];
    R.findIndex(R.propEq('a', 2))(xs); //=> 1
    R.findIndex(R.propEq('a', 4))(xs); //=> -1

    Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns number

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns (list: readonly T[]) => number

      • (list: readonly T[]): number
      • Parameters

        • list: readonly T[]

        Returns number

  • findLast<T, P>(pred: (val: T) => val is P, list: readonly T[]): P | undefined
  • findLast<T>(pred: (val: T) => boolean, list: readonly T[]): T | undefined
  • findLast<T, P>(pred: (val: T) => val is P): (list: readonly T[]) => P | undefined
  • findLast<T>(pred: (val: T) => boolean): (list: readonly T[]) => T | undefined
  • Returns the last element of the list which matches the predicate, or undefined if no element matches.

    Acts as a transducer if a transformer is given in list position.

    See also transduce.

    example
    const xs = [{a: 1, b: 0}, {a:1, b: 1}];
    R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1}
    R.findLast(R.propEq('a', 4))(xs); //=> undefined

    Type parameters

    • T

    • P

    Parameters

    • pred: (val: T) => val is P
        • (val: T): val is P
        • Parameters

          • val: T

          Returns val is P

    • list: readonly T[]

    Returns P | undefined

  • Type parameters

    • T

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    • list: readonly T[]

    Returns T | undefined

  • Type parameters

    • T

    • P

    Parameters

    • pred: (val: T) => val is P
        • (val: T): val is P
        • Parameters

          • val: T

          Returns val is P

    Returns (list: readonly T[]) => P | undefined

      • (list: readonly T[]): P | undefined
      • Parameters

        • list: readonly T[]

        Returns P | undefined

  • Type parameters

    • T

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    Returns (list: readonly T[]) => T | undefined

      • (list: readonly T[]): T | undefined
      • Parameters

        • list: readonly T[]

        Returns T | undefined

  • findLastIndex<T>(fn: (a: T) => boolean, list: readonly T[]): number
  • findLastIndex<T>(fn: (a: T) => boolean): (list: readonly T[]) => number
  • Returns the index of the last element of the list which matches the predicate, or -1 if no element matches.

    Acts as a transducer if a transformer is given in list position.

    See also lastIndexOf, transduce.

    example
    const xs = [{a: 1, b: 0}, {a:1, b: 1}];
    R.findLastIndex(R.propEq('a', 1))(xs); //=> 1
    R.findLastIndex(R.propEq('a', 4))(xs); //=> -1

    Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns number

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns (list: readonly T[]) => number

      • (list: readonly T[]): number
      • Parameters

        • list: readonly T[]

        Returns number

  • flatten<T>(list: T): _.T.Flatten<T>
  • Returns a new list by pulling every item out of it (and all its sub-arrays) and putting them in a new array, depth-first.

    See also unnest.

    example
    R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]);
    //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

    Type parameters

    • T: readonly any[]

    Parameters

    • list: T

    Returns _.T.Flatten<T>

  • flip<T, U, TResult>(fn: (arg0: T, arg1: U) => TResult): (arg1: U, arg0?: T) => TResult
  • flip<F, P>(fn: F): _.F.Curry<(...args: _.T.Merge<[P[1], P[0]], P>) => _.F.Return<F>>
  • Flips the order of the first two arguments to the given function.

    example
    const mergeThree = <T>(a: T, b: T, c: T) => ([] as T[]).concat(a, b, c);

    mergeThree(1, 2, 3); //=> [1, 2, 3]

    R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3]

    Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (arg0: T, arg1: U) => TResult
        • (arg0: T, arg1: U): TResult
        • Parameters

          • arg0: T
          • arg1: U

          Returns TResult

    Returns (arg1: U, arg0?: T) => TResult

      • (arg1: U, arg0?: T): TResult
      • Flips the order of the first two arguments to the given function.

        example
        const mergeThree = <T>(a: T, b: T, c: T) => ([] as T[]).concat(a, b, c);

        mergeThree(1, 2, 3); //=> [1, 2, 3]

        R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3]

        Parameters

        • arg1: U
        • Optional arg0: T

        Returns TResult

  • Type parameters

    Parameters

    • fn: F

    Returns _.F.Curry<(...args: _.T.Merge<[P[1], P[0]], P>) => _.F.Return<F>>

  • forEach<T>(fn: (x: T) => void, list: readonly T[]): T[]
  • forEach<T>(fn: (x: T) => void): (list: readonly T[]) => T[]
  • forEach<T>(fn: (x: T) => void, list: readonly T[]): T[]
  • forEach<T>(fn: (x: T) => void): (list: readonly T[]) => T[]
  • Iterate over the given list, calling the given function for each element in the list.

    note

    R.forEach does not skip deleted or unassigned indices (sparse arrays), unlike the native Array.prototype.forEach method.

    Also note that, unlike Array.prototype.forEach, R.forEach returns the original array. In some libraries this function is named each.

    Dispatches to the forEach method of the second argument, if present.

    example
    const printXPlusFive = (x: number) => console.log(x + 5);
    R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3]
    // logs 6
    // logs 7
    // logs 8

    Type parameters

    • T

    Parameters

    • fn: (x: T) => void
        • (x: T): void
        • Parameters

          • x: T

          Returns void

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • fn: (x: T) => void
        • (x: T): void
        • Parameters

          • x: T

          Returns void

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • Type parameters

    • T

    Parameters

    • fn: (x: T) => void
        • (x: T): void
        • Parameters

          • x: T

          Returns void

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • fn: (x: T) => void
        • (x: T): void
        • Parameters

          • x: T

          Returns void

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • forEachObjIndexed<T>(fn: (value: T[keyof T], key: keyof T, obj: T) => void, obj: T): T
  • forEachObjIndexed<T>(fn: (value: T[keyof T], key: keyof T, obj: T) => void): (obj: T) => T
  • Iterate over the given object, calling the given function for each key and value in the object.

    example
    const printKeyConcatValue = (value: unknown, key: string) => console.log(key + ':' + value);
    R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2}
    // logs x:1
    // logs y:2

    Type parameters

    • T

    Parameters

    • fn: (value: T[keyof T], key: keyof T, obj: T) => void
        • (value: T[keyof T], key: keyof T, obj: T): void
        • Parameters

          • value: T[keyof T]
          • key: keyof T
          • obj: T

          Returns void

    • obj: T

    Returns T

  • Type parameters

    • T

    Parameters

    • fn: (value: T[keyof T], key: keyof T, obj: T) => void
        • (value: T[keyof T], key: keyof T, obj: T): void
        • Parameters

          • value: T[keyof T]
          • key: keyof T
          • obj: T

          Returns void

    Returns (obj: T) => T

      • (obj: T): T
      • Parameters

        • obj: T

        Returns T

  • fromPairs<V>(pairs: readonly readonly [string, V][] | readonly readonly [number, V][]): {}
  • Creates a new object from a list key-value pairs. If a key appears in multiple pairs, the rightmost pair is included in the object.

    See also toPairs, pair.

    example
    R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
    

    Type parameters

    • V

    Parameters

    • pairs: readonly readonly [string, V][] | readonly readonly [number, V][]

    Returns {}

    • [index: string]: V
  • groupBy<T, K>(fn: (a: T) => K, list: readonly T[]): Record<K, T[]>
  • groupBy<T, K>(fn: (a: T) => K): (list: readonly T[]) => Record<K, T[]>
  • Splits a list into sub-lists stored in an object, based on the result of calling a key-returning function on each element, and grouping the results according to values returned.

    Dispatches to the groupBy method of the second argument, if present.

    Acts as a transducer if a transformer is given in list position.

    See also reduceBy, indexBy, transduce.

    example
    type Student = { name: string; score: number; }

    const byGrade = R.groupBy((student: Student) => {
    const score = student.score;
    return score < 65 ? 'F' :
    score < 70 ? 'D' :
    score < 80 ? 'C' :
    score < 90 ? 'B' : 'A';
    });
    const students = [{name: 'Abby', score: 84},
    {name: 'Eddy', score: 58},
    // ...
    {name: 'Jack', score: 69}];
    byGrade(students);
    // {
    // 'A': [{name: 'Dianne', score: 99}],
    // 'B': [{name: 'Abby', score: 84}]
    // // ...,
    // 'F': [{name: 'Eddy', score: 58}]
    // }

    Type parameters

    • T

    • K: string = string

    Parameters

    • fn: (a: T) => K
        • (a: T): K
        • Parameters

          • a: T

          Returns K

    • list: readonly T[]

    Returns Record<K, T[]>

  • Type parameters

    • T

    • K: string = string

    Parameters

    • fn: (a: T) => K
        • (a: T): K
        • Parameters

          • a: T

          Returns K

    Returns (list: readonly T[]) => Record<K, T[]>

      • (list: readonly T[]): Record<K, T[]>
      • Parameters

        • list: readonly T[]

        Returns Record<K, T[]>

  • groupWith<T>(fn: (x: T, y: T) => boolean): (list: readonly T[]) => T[][]
  • groupWith<T>(fn: (x: T, y: T) => boolean, list: readonly T[]): T[][]
  • groupWith<T>(fn: (x: T, y: T) => boolean, list: string): string[]
  • Takes a list and returns a list of lists where every adjacent element of each sublist satisfies the given predicate.

    example
    R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21])
    //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]]

    R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21])
    //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]]

    R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21])
    //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]]

    const isVowel = R.test(/^[aeiou]$/i);
    R.groupWith(R.eqBy(isVowel), 'aestiou')
    //=> ['ae', 'st', 'iou']

    Type parameters

    • T

    Parameters

    • fn: (x: T, y: T) => boolean
        • (x: T, y: T): boolean
        • Parameters

          • x: T
          • y: T

          Returns boolean

    Returns (list: readonly T[]) => T[][]

      • (list: readonly T[]): T[][]
      • Takes a list and returns a list of lists where every adjacent element of each sublist satisfies the given predicate.

        example
        R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21])
        //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]]

        R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21])
        //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]]

        R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21])
        //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]]

        const isVowel = R.test(/^[aeiou]$/i);
        R.groupWith(R.eqBy(isVowel), 'aestiou')
        //=> ['ae', 'st', 'iou']

        Parameters

        • list: readonly T[]

        Returns T[][]

  • Type parameters

    • T

    Parameters

    • fn: (x: T, y: T) => boolean
        • (x: T, y: T): boolean
        • Parameters

          • x: T
          • y: T

          Returns boolean

    • list: readonly T[]

    Returns T[][]

  • Type parameters

    • T

    Parameters

    • fn: (x: T, y: T) => boolean
        • (x: T, y: T): boolean
        • Parameters

          • x: T
          • y: T

          Returns boolean

    • list: string

    Returns string[]

  • gt(__: Placeholder, b: number): (a: number) => boolean
  • gt(__: Placeholder): (b: number, a: number) => boolean
  • gt(a: number, b: number): boolean
  • gt(a: string, b: string): boolean
  • gt(a: number): (b: number) => boolean
  • Returns true if the first parameter is greater than the second; false otherwise.

    See also gte, lt, lte.

    example
    R.gt(2, 1); //=> true
    R.gt(2, 2); //=> false
    R.gt(2, 3); //=> false
    R.gt('a', 'z'); //=> false
    R.gt('z', 'a'); //=> true

    Parameters

    Returns (a: number) => boolean

      • (a: number): boolean
      • Returns true if the first parameter is greater than the second; false otherwise.

        See also gte, lt, lte.

        example
        R.gt(2, 1); //=> true
        R.gt(2, 2); //=> false
        R.gt(2, 3); //=> false
        R.gt('a', 'z'); //=> false
        R.gt('z', 'a'); //=> true

        Parameters

        • a: number

        Returns boolean

  • Parameters

    Returns (b: number, a: number) => boolean

      • (b: number, a: number): boolean
      • Parameters

        • b: number
        • a: number

        Returns boolean

  • Parameters

    • a: number
    • b: number

    Returns boolean

  • Parameters

    • a: string
    • b: string

    Returns boolean

  • Parameters

    • a: number

    Returns (b: number) => boolean

      • (b: number): boolean
      • Parameters

        • b: number

        Returns boolean

  • gte(__: Placeholder, b: number): (a: number) => boolean
  • gte(__: Placeholder): (b: number, a: number) => boolean
  • gte(a: number, b: number): boolean
  • gte(a: string, b: string): boolean
  • gte(a: number): (b: number) => boolean
  • Returns true if the first parameter is greater than or equal to the second; false otherwise.

    See also gt, lt, lte.

    example
    R.gte(2, 1); //=> true
    R.gte(2, 2); //=> true
    R.gte(2, 3); //=> false
    R.gte('a', 'z'); //=> false
    R.gte('z', 'a'); //=> true

    Parameters

    Returns (a: number) => boolean

      • (a: number): boolean
      • Returns true if the first parameter is greater than or equal to the second; false otherwise.

        See also gt, lt, lte.

        example
        R.gte(2, 1); //=> true
        R.gte(2, 2); //=> true
        R.gte(2, 3); //=> false
        R.gte('a', 'z'); //=> false
        R.gte('z', 'a'); //=> true

        Parameters

        • a: number

        Returns boolean

  • Parameters

    Returns (b: number, a: number) => boolean

      • (b: number, a: number): boolean
      • Parameters

        • b: number
        • a: number

        Returns boolean

  • Parameters

    • a: number
    • b: number

    Returns boolean

  • Parameters

    • a: string
    • b: string

    Returns boolean

  • Parameters

    • a: number

    Returns (b: number) => boolean

      • (b: number): boolean
      • Parameters

        • b: number

        Returns boolean

  • has(__: Placeholder, obj: unknown): (s: string) => boolean
  • has(__: Placeholder): <P>(obj: unknown, s: P) => obj is ObjectHavingSome<P>
  • has<P>(s: P, obj: unknown): obj is Clean<{ [ K in string]: { [ P in string]: unknown } }[P]>
  • has<P>(s: P): (obj: unknown) => obj is ObjectHavingSome<P>
  • Returns whether or not an object has an own property with the specified name.

    example
    const hasName = R.has('name');
    hasName({name: 'alice'}); //=> true
    hasName({name: 'bob'}); //=> true
    hasName({}); //=> false

    const point = {x: 0, y: 0};
    const pointHas = R.has(R.__, point);
    pointHas('x'); //=> true
    pointHas('y'); //=> true
    pointHas('z'); //=> false

    Parameters

    Returns (s: string) => boolean

      • (s: string): boolean
      • Returns whether or not an object has an own property with the specified name.

        example
        const hasName = R.has('name');
        hasName({name: 'alice'}); //=> true
        hasName({name: 'bob'}); //=> true
        hasName({}); //=> false

        const point = {x: 0, y: 0};
        const pointHas = R.has(R.__, point);
        pointHas('x'); //=> true
        pointHas('y'); //=> true
        pointHas('z'); //=> false

        Parameters

        • s: string

        Returns boolean

  • Parameters

    Returns <P>(obj: unknown, s: P) => obj is ObjectHavingSome<P>

  • Type parameters

    • P: string

    Parameters

    • s: P
    • obj: unknown

    Returns obj is Clean<{ [ K in string]: { [ P in string]: unknown } }[P]>

  • Type parameters

    • P: string

    Parameters

    • s: P

    Returns (obj: unknown) => obj is ObjectHavingSome<P>

  • hasIn<T>(s: string, obj: T): boolean
  • hasIn(s: string): <T>(obj: T) => boolean
  • Returns whether or not an object or its prototype chain has a property with the specified name.

    example
    class Rectangle {
    constructor(public width: number, public height: number) {}

    area() {
    return this.width * this.height;
    }
    }

    const square = new Rectangle(2, 2);
    R.hasIn('width', square); //=> true
    R.hasIn('area', square); //=> true

    Type parameters

    • T

    Parameters

    • s: string
    • obj: T

    Returns boolean

  • Parameters

    • s: string

    Returns <T>(obj: T) => boolean

      • <T>(obj: T): boolean
      • Type parameters

        • T

        Parameters

        • obj: T

        Returns boolean

  • hasPath<T>(list: readonly string[], obj: T): boolean
  • hasPath(list: readonly string[]): <T>(obj: T) => boolean
  • Returns whether or not a path exists in an object. Only the object's own properties are checked.

    See also has.

    example
    R.hasPath(['a', 'b'], {a: {b: 2}});         // => true
    R.hasPath(['a', 'b'], {a: {b: undefined}}); // => true
    R.hasPath(['a', 'b'], {a: {c: 2}}); // => false
    R.hasPath(['a', 'b'], {}); // => false

    Type parameters

    • T

    Parameters

    • list: readonly string[]
    • obj: T

    Returns boolean

  • Parameters

    • list: readonly string[]

    Returns <T>(obj: T) => boolean

      • <T>(obj: T): boolean
      • Type parameters

        • T

        Parameters

        • obj: T

        Returns boolean

  • head(str: string): string
  • head(list: readonly []): undefined
  • head<T>(list: readonly T[]): T | undefined
  • Returns the first element in a list. In some libraries this function is named first.

    See also tail, init, last.

    example
    R.head(['fi', 'fo', 'fum']); //=> 'fi'
    R.head([]); //=> undefined

    R.head('abc'); //=> 'a'
    R.head(''); //=> ''

    Parameters

    • str: string

    Returns string

  • Parameters

    • list: readonly []

    Returns undefined

  • Type parameters

    • T

    Parameters

    • list: readonly T[]

    Returns T | undefined

  • identical<T>(a: T, b: T): boolean
  • identical<T>(a: T): (b: T) => boolean
  • Returns true if its arguments are identical, false otherwise. Values are identical if they reference the same memory. NaN is identical to NaN; 0 and -0 are not identical.

    note

    This is merely a curried version of ES6 Object.is.

    example
    const o = {};
    R.identical(o, o); //=> true
    R.identical(1, 1); //=> true
    R.identical<string | number>(1, '1'); //=> false
    R.identical([], []); //=> false
    R.identical(0, -0); //=> false
    R.identical(NaN, NaN); //=> true

    Type parameters

    • T

    Parameters

    • a: T
    • b: T

    Returns boolean

  • Type parameters

    • T

    Parameters

    • a: T

    Returns (b: T) => boolean

      • (b: T): boolean
      • Parameters

        • b: T

        Returns boolean

  • identity<T>(a: T): T
  • A function that returns its argument. Good as a default or placeholder function.

    example
    R.identity(1); //=> 1

    const obj = {};
    R.identity(obj) === obj; //=> true

    Type parameters

    • T

    Parameters

    • a: T

    Returns T

  • ifElse<T, TF, TOnTrueResult, TOnFalseResult>(pred: PredTypeguard<T, TF>, onTrue: (a: TF) => TOnTrueResult, onFalse: (a: Exclude<T, TF>) => TOnFalseResult): (a: T) => TOnTrueResult | TOnFalseResult
  • ifElse<TArgs, TOnTrueResult, TOnFalseResult>(fn: Pred<TArgs>, onTrue: (...args: TArgs) => TOnTrueResult, onFalse: (...args: TArgs) => TOnFalseResult): (...args: TArgs) => TOnTrueResult | TOnFalseResult
  • Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

    See also unless, when, cond.

    example
    const incCount = R.ifElse(
    R.has('count'),
    R.over(R.lensProp<{ count: number; }>('count'), R.inc),
    R.assoc('count', 1)
    );
    incCount({ count: 1 }); //=> { count: 2 }

    Type parameters

    • T

    • TF

    • TOnTrueResult

    • TOnFalseResult

    Parameters

    • pred: PredTypeguard<T, TF>
    • onTrue: (a: TF) => TOnTrueResult
        • (a: TF): TOnTrueResult
        • Parameters

          • a: TF

          Returns TOnTrueResult

    • onFalse: (a: Exclude<T, TF>) => TOnFalseResult
        • (a: Exclude<T, TF>): TOnFalseResult
        • Parameters

          • a: Exclude<T, TF>

          Returns TOnFalseResult

    Returns (a: T) => TOnTrueResult | TOnFalseResult

      • (a: T): TOnTrueResult | TOnFalseResult
      • Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

        See also unless, when, cond.

        example
        const incCount = R.ifElse(
        R.has('count'),
        R.over(R.lensProp<{ count: number; }>('count'), R.inc),
        R.assoc('count', 1)
        );
        incCount({ count: 1 }); //=> { count: 2 }

        Parameters

        • a: T

        Returns TOnTrueResult | TOnFalseResult

  • Type parameters

    • TArgs: any[]

    • TOnTrueResult

    • TOnFalseResult

    Parameters

    • fn: Pred<TArgs>
    • onTrue: (...args: TArgs) => TOnTrueResult
        • (...args: TArgs): TOnTrueResult
        • Parameters

          • Rest ...args: TArgs

          Returns TOnTrueResult

    • onFalse: (...args: TArgs) => TOnFalseResult
        • (...args: TArgs): TOnFalseResult
        • Parameters

          • Rest ...args: TArgs

          Returns TOnFalseResult

    Returns (...args: TArgs) => TOnTrueResult | TOnFalseResult

      • (...args: TArgs): TOnTrueResult | TOnFalseResult
      • Parameters

        • Rest ...args: TArgs

        Returns TOnTrueResult | TOnFalseResult

  • inc(n: number): number
  • Increments its argument.

    See also dec.

    example
    R.inc(42); //=> 43
    

    Parameters

    • n: number

    Returns number

  • includes(__: Placeholder, list: string | readonly string[]): (s: string) => boolean
  • includes<T>(__: Placeholder, list: readonly T[]): (target: T) => boolean
  • includes(__: Placeholder): (list: readonly string[] | string, s: string) => boolean
  • includes<T>(__: Placeholder): (list: readonly T[], target: T) => boolean
  • includes(s: string, list: string | readonly string[]): boolean
  • includes(s: string): (list: readonly string[] | string) => boolean
  • includes<T>(target: T, list: readonly T[]): boolean
  • includes<T>(target: T): (list: readonly T[]) => boolean
  • Returns true if the specified value is equal, in R.equals terms, to at least one element of the given list; false otherwise. Also works with strings.

    See also any.

    example
    R.includes(3, [1, 2, 3]);   //=> true
    R.includes(4, [1, 2, 3]); //=> false
    R.includes([42], <a href="common.web3.uniswap_sdk.html#WETH.__type.42">42</a>); //=> true
    R.includes('ba', 'banana'); //=> true
    R.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true

    Parameters

    Returns (s: string) => boolean

      • (s: string): boolean
      • Returns true if the specified value is equal, in R.equals terms, to at least one element of the given list; false otherwise. Also works with strings.

        See also any.

        example
        R.includes(3, [1, 2, 3]);   //=> true
        R.includes(4, [1, 2, 3]); //=> false
        R.includes([42], <a href="common.web3.uniswap_sdk.html#WETH.__type.42">42</a>); //=> true
        R.includes('ba', 'banana'); //=> true
        R.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true

        Parameters

        • s: string

        Returns boolean

  • Type parameters

    • T

    Parameters

    Returns (target: T) => boolean

      • (target: T): boolean
      • Parameters

        • target: T

        Returns boolean

  • Parameters

    Returns (list: readonly string[] | string, s: string) => boolean

      • (list: readonly string[] | string, s: string): boolean
      • Parameters

        • list: readonly string[] | string
        • s: string

        Returns boolean

  • Type parameters

    • T

    Parameters

    Returns (list: readonly T[], target: T) => boolean

      • (list: readonly T[], target: T): boolean
      • Parameters

        • list: readonly T[]
        • target: T

        Returns boolean

  • Parameters

    • s: string
    • list: string | readonly string[]

    Returns boolean

  • Parameters

    • s: string

    Returns (list: readonly string[] | string) => boolean

      • (list: readonly string[] | string): boolean
      • Parameters

        • list: readonly string[] | string

        Returns boolean

  • Type parameters

    • T

    Parameters

    • target: T
    • list: readonly T[]

    Returns boolean

  • Type parameters

    • T

    Parameters

    • target: T

    Returns (list: readonly T[]) => boolean

      • (list: readonly T[]): boolean
      • Parameters

        • list: readonly T[]

        Returns boolean

  • indexBy<T, K>(fn: (a: T) => K, list: readonly T[]): { [ key in K]: T }
  • indexBy<T, K>(fn: (a: T) => K, list: readonly T[]): { [ key in NonNullable<K>]?: T }
  • indexBy<T, K>(fn: (a: T) => K): (list: readonly T[]) => { [ key in K]: T }
  • indexBy<T, K>(fn: (a: T) => undefined | K): (list: readonly T[]) => { [ key in NonNullable<K>]?: T }
  • Given a function that generates a key, turns a list of objects into an object indexing the objects by the given key.

    note

    If multiple objects generate the same value for the indexing key only the last value will be included in the generated object.

    Acts as a transducer if a transformer is given in list position.

    See also groupBy, transduce.

    example
    const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}];
    R.indexBy(R.prop('id'), list);
    //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}

    Type parameters

    • T

    • K: string | number = string

    Parameters

    • fn: (a: T) => K
        • (a: T): K
        • Parameters

          • a: T

          Returns K

    • list: readonly T[]

    Returns { [ key in K]: T }

  • Type parameters

    • T

    • K: undefined | string | number = string

    Parameters

    • fn: (a: T) => K
        • (a: T): K
        • Parameters

          • a: T

          Returns K

    • list: readonly T[]

    Returns { [ key in NonNullable<K>]?: T }

  • Type parameters

    • T

    • K: string | number = string

    Parameters

    • fn: (a: T) => K
        • (a: T): K
        • Parameters

          • a: T

          Returns K

    Returns (list: readonly T[]) => { [ key in K]: T }

      • (list: readonly T[]): { [ key in K]: T }
      • Parameters

        • list: readonly T[]

        Returns { [ key in K]: T }

  • Type parameters

    • T

    • K: undefined | string | number = string

    Parameters

    • fn: (a: T) => undefined | K
        • (a: T): undefined | K
        • Parameters

          • a: T

          Returns undefined | K

    Returns (list: readonly T[]) => { [ key in NonNullable<K>]?: T }

      • (list: readonly T[]): { [ key in NonNullable<K>]?: T }
      • Parameters

        • list: readonly T[]

        Returns { [ key in NonNullable<K>]?: T }

  • indexOf(target: string, list: string | readonly string[]): number
  • indexOf(target: string): (list: readonly string[] | string) => number
  • indexOf<T>(target: T, list: readonly T[]): number
  • indexOf<T>(target: T): (list: readonly T[]) => number
  • Returns the position of the first occurrence of an item in an array, or -1 if the item is not included in the array. R.equals is used to determine equality.

    example
    R.indexOf(3, [1,2,3,4]);  //=> 2
    R.indexOf(10, [1,2,3,4]); //=> -1

    Parameters

    • target: string
    • list: string | readonly string[]

    Returns number

  • Parameters

    • target: string

    Returns (list: readonly string[] | string) => number

      • (list: readonly string[] | string): number
      • Parameters

        • list: readonly string[] | string

        Returns number

  • Type parameters

    • T

    Parameters

    • target: T
    • list: readonly T[]

    Returns number

  • Type parameters

    • T

    Parameters

    • target: T

    Returns (list: readonly T[]) => number

      • (list: readonly T[]): number
      • Parameters

        • list: readonly T[]

        Returns number

  • init<T>(list: readonly T[]): T[]
  • init(list: string): string
  • Returns all but the last element of the given list or string.

    See also last, head, tail.

    example
    R.init([1, 2, 3]); //=> [1, 2]
    R.init([1, 2]); //=> [1]
    R.init([1]); //=> []
    R.init([]); //=> []

    R.init('abc'); //=> 'ab'
    R.init('ab'); //=> 'a'
    R.init('a'); //=> ''
    R.init(''); //=> ''

    Type parameters

    • T

    Parameters

    • list: readonly T[]

    Returns T[]

  • Parameters

    • list: string

    Returns string

  • innerJoin<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[], list2: readonly T2[]): T1[]
  • innerJoin<T1, T2>(pred: (a: T1, b: T2) => boolean): (list1: readonly T1[], list2: readonly T2[]) => T1[]
  • innerJoin<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: readonly T1[]): (list2: readonly T2[]) => T1[]
  • Takes a predicate pred, a list xs, and a list ys, and returns a list xs' comprising each of the elements of xs which is equal to one or more elements of ys according to pred.

    pred must be a binary function expecting an element from each list.

    xs, ys, and xs' are treated as sets, semantically, so ordering should not be significant, but since xs' is ordered the implementation guarantees that its values are in the same order as they appear in xs. Duplicates are not removed, so xs' may contain duplicates if xs contains duplicates.

    See also intersection.

    example
    R.innerJoin(
    (record, id) => record.id === id,
    [{id: 824, name: 'Richie Furay'},
    {id: 956, name: 'Dewey Martin'},
    {id: 313, name: 'Bruce Palmer'},
    {id: 456, name: 'Stephen Stills'},
    {id: 177, name: 'Neil Young'}],
    [177, 456, 999]
    );
    //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}]

    Type parameters

    • T1

    • T2

    Parameters

    • pred: (a: T1, b: T2) => boolean
        • (a: T1, b: T2): boolean
        • Parameters

          • a: T1
          • b: T2

          Returns boolean

    • list1: readonly T1[]
    • list2: readonly T2[]

    Returns T1[]

  • Type parameters

    • T1

    • T2

    Parameters

    • pred: (a: T1, b: T2) => boolean
        • (a: T1, b: T2): boolean
        • Parameters

          • a: T1
          • b: T2

          Returns boolean

    Returns (list1: readonly T1[], list2: readonly T2[]) => T1[]

      • (list1: readonly T1[], list2: readonly T2[]): T1[]
      • Parameters

        • list1: readonly T1[]
        • list2: readonly T2[]

        Returns T1[]

  • Type parameters

    • T1

    • T2

    Parameters

    • pred: (a: T1, b: T2) => boolean
        • (a: T1, b: T2): boolean
        • Parameters

          • a: T1
          • b: T2

          Returns boolean

    • list1: readonly T1[]

    Returns (list2: readonly T2[]) => T1[]

      • (list2: readonly T2[]): T1[]
      • Parameters

        • list2: readonly T2[]

        Returns T1[]

  • insert<T>(index: number, elt: T, list: readonly T[]): T[]
  • insert<T>(index: number, elt: T): (list: readonly T[]) => T[]
  • insert(index: number): <T>(elt: T, list: readonly T[]) => T[]
  • Returns a copy of the list with the element inserted at the index.

    example
    R.insert<string | number>(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4]
    

    Type parameters

    • T

    Parameters

    • index: number
    • elt: T
    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • index: number
    • elt: T

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • Parameters

    • index: number

    Returns <T>(elt: T, list: readonly T[]) => T[]

      • <T>(elt: T, list: readonly T[]): T[]
      • Type parameters

        • T

        Parameters

        • elt: T
        • list: readonly T[]

        Returns T[]

  • insertAll<T>(index: number, elts: readonly T[], list: readonly T[]): T[]
  • insertAll<T>(index: number, elts: readonly T[]): (list: readonly T[]) => T[]
  • insertAll(index: number): <T>(elts: readonly T[], list: readonly T[]) => T[]
  • Returns a copy of the list with the elements inserted at the index.

    example
    R.insertAll<string | number>(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4]
    

    Type parameters

    • T

    Parameters

    • index: number
    • elts: readonly T[]
    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • index: number
    • elts: readonly T[]

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • Parameters

    • index: number

    Returns <T>(elts: readonly T[], list: readonly T[]) => T[]

      • <T>(elts: readonly T[], list: readonly T[]): T[]
      • Type parameters

        • T

        Parameters

        • elts: readonly T[]
        • list: readonly T[]

        Returns T[]

  • intersection<T>(list1: readonly T[], list2: readonly T[]): T[]
  • intersection<T>(list1: readonly T[]): (list2: readonly T[]) => T[]
  • Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists.

    See also innerJoin.

    example
    R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3]
    

    Type parameters

    • T

    Parameters

    • list1: readonly T[]
    • list2: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • list1: readonly T[]

    Returns (list2: readonly T[]) => T[]

      • (list2: readonly T[]): T[]
      • Parameters

        • list2: readonly T[]

        Returns T[]

  • intersperse<T>(separator: T, list: readonly T[]): T[]
  • intersperse<T>(separator: T): (list: readonly T[]) => T[]
  • Creates a new list with the separator interposed between elements.

    Dispatches to the intersperse method of the second argument, if present.

    example
    R.intersperse('a', ['b', 'n', 'n', 's']); //=> ['b', 'a', 'n', 'a', 'n', 'a', 's']
    

    Type parameters

    • T

    Parameters

    • separator: T
    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • separator: T

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • into<T>(acc: any, xf: AnyFunction, list: readonly T[]): T[]
  • into<T, R>(acc: any, xf: (...args: any[]) => R[], list: readonly T[]): R[]
  • into(acc: any, xf: AnyFunction): <T>(list: readonly T[]) => T[]
  • into(acc: any): <T>(xf: AnyFunction, list: readonly T[]) => T[]
  • Transforms the items of the list with the transducer and appends the transformed items to the accumulator using an appropriate iterator function based on the accumulator type.

    The accumulator can be an array, string, object or a transformer. Iterated items will be appended to arrays and concatenated to strings. Objects will be merged directly or 2-item tuples will be merged as key, value pairs.

    The accumulator can also be a transformer object that provides:

    • A 2-arity iterator function, which is passed directly to reduce.
    • A 0-arity initial value function, which is used to provide the initial accumulator.
    • A 1-arity result extraction function, which is used to convert the final accumulator into the return type. In most cases is it is R.identity.

    The iteration is performed with R.reduce after initializing the transducer.

    See also transduce.

    example
    const numbers = [1, 2, 3, 4];
    const transducer = R.compose(R.map(R.add(1)), R.take(2));

    R.into([], transducer, numbers); //=> [2, 3]

    const intoArray = R.into([]);
    intoArray(transducer, numbers); //=> [2, 3]

    Type parameters

    • T

    Parameters

    Returns T[]

  • Type parameters

    • T

    • R

    Parameters

    • acc: any
    • xf: (...args: any[]) => R[]
        • (...args: any[]): R[]
        • Parameters

          • Rest ...args: any[]

          Returns R[]

    • list: readonly T[]

    Returns R[]

  • Parameters

    Returns <T>(list: readonly T[]) => T[]

      • <T>(list: readonly T[]): T[]
      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns T[]

  • Parameters

    • acc: any

    Returns <T>(xf: AnyFunction, list: readonly T[]) => T[]

      • Type parameters

        • T

        Parameters

        Returns T[]

  • invert<T>(obj: T): {}
  • Same as R.invertObj, however this accounts for objects with duplicate values by putting the values into an array.

    See also invertObj.

    example
    const raceResultsByFirstName = {
    first: 'alice',
    second: 'jake',
    third: 'alice',
    };
    R.invert(raceResultsByFirstName);
    //=> { 'alice': ['first', 'third'], 'jake': ['second'] }

    Type parameters

    • T

    Parameters

    • obj: T

    Returns {}

    • [index: string]: string[]
  • invertObj(obj: {} | {}): {}
  • Returns a new object with the keys of the given object as values, and the values of the given object as keys.

    note

    If multiple objects generate the same value for the indexing key only the last value will be included in the generated object.

    See also invert.

    example
    const raceResults = {
    first: 'alice',
    second: 'jake'
    };
    R.invertObj(raceResults);
    //=> { 'alice': 'first', 'jake':'second' }

    // Alternatively:
    const raceResults = ['alice', 'jake'];
    R.invertObj(raceResults);
    //=> { 'alice': '0', 'jake':'1' }

    Parameters

    • obj: {} | {}

    Returns {}

    • [index: string]: string
  • invoker(arity: number, method: string): (...args: unknown[]) => any
  • Turns a named method with a specified arity into a function that can be called directly supplied with arguments and a target object.

    The returned function is curried and accepts arity + 1 parameters where the final parameter is the target object.

    example
    const sliceFrom = R.invoker<(start: number, s: string) => string>(1, 'slice');
    sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm'
    const sliceFrom6 = R.invoker<(start: number, end: number, s: string) => string>(2, 'slice')(6);
    sliceFrom6(8, 'abcdefghijklm'); //=> 'gh'

    const dog = {
    speak: async () => 'Woof!'
    };
    const speak = R.invoker<(speaker: { speak: () => Promise<string> }) => Promise<string>>(0, 'speak');
    speak(dog).then(console.log) //~> 'Woof!'

    Parameters

    • arity: number
    • method: string

    Returns (...args: unknown[]) => any

      • (...args: unknown[]): any
      • Turns a named method with a specified arity into a function that can be called directly supplied with arguments and a target object.

        The returned function is curried and accepts arity + 1 parameters where the final parameter is the target object.

        example
        const sliceFrom = R.invoker<(start: number, s: string) => string>(1, 'slice');
        sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm'
        const sliceFrom6 = R.invoker<(start: number, end: number, s: string) => string>(2, 'slice')(6);
        sliceFrom6(8, 'abcdefghijklm'); //=> 'gh'

        const dog = {
        speak: async () => 'Woof!'
        };
        const speak = R.invoker<(speaker: { speak: () => Promise<string> }) => Promise<string>>(0, 'speak');
        speak(dog).then(console.log) //~> 'Woof!'

        Parameters

        • Rest ...args: unknown[]

        Returns any

  • is<C>(ctor: C, val: any): val is ReturnType<C>
  • is<C>(ctor: C, val: any): val is InstanceType<C>
  • is<C>(ctor: C): (val: any) => val is ReturnType<C>
  • is<C>(ctor: C): (val: any) => val is InstanceType<C>
  • See if an object (val) is an instance of the supplied constructor. This function will check up the inheritance chain, if any. If val was created using Object.create, R.is(Object, val) === true.

    See also propIs.

    Type parameters

    Parameters

    • ctor: C
    • val: any

    Returns val is ReturnType<C>

  • Type parameters

    Parameters

    • ctor: C
    • val: any

    Returns val is InstanceType<C>

  • Type parameters

    Parameters

    • ctor: C

    Returns (val: any) => val is ReturnType<C>

      • (val: any): val is ReturnType<C>
      • Parameters

        • val: any

        Returns val is ReturnType<C>

  • Type parameters

    Parameters

    • ctor: C

    Returns (val: any) => val is InstanceType<C>

      • (val: any): val is InstanceType<C>
      • Parameters

        • val: any

        Returns val is InstanceType<C>

  • isEmpty(value: any): boolean
  • Returns true if the given value is its type's empty value; false otherwise.

    See also empty.

    example
    R.isEmpty([1, 2, 3]);           //=> false
    R.isEmpty([]); //=> true
    R.isEmpty(''); //=> true
    R.isEmpty(null); //=> false
    R.isEmpty({}); //=> true
    R.isEmpty({length: 0}); //=> false
    R.isEmpty(Uint8Array.from([])); //=> true

    Parameters

    • value: any

    Returns boolean

  • isNil(value: any): value is undefined | null
  • Checks if the input value is null or undefined.

    example
    R.isNil(null); //=> true
    R.isNil(undefined); //=> true
    R.isNil(0); //=> false
    R.isNil([]); //=> false

    Parameters

    • value: any

    Returns value is undefined | null

  • join(x: string, xs: readonly any[]): string
  • join(x: string): (xs: readonly any[]) => string
  • Returns a string made by inserting the given separator between each element and concatenating all the elements into a single string.

    See also split.

    example
    const spacer = R.join(' ');
    spacer(['a', 2, 3.4]); //=> 'a 2 3.4'
    R.join('|', [1, 2, 3]); //=> '1|2|3'

    Parameters

    • x: string
    • xs: readonly any[]

    Returns string

  • Parameters

    • x: string

    Returns (xs: readonly any[]) => string

      • (xs: readonly any[]): string
      • Parameters

        • xs: readonly any[]

        Returns string

  • juxt<A, R1>(fns: [(...args: A) => R1]): (...args: A) => [R1]
  • juxt<A, R1, R2>(fns: [(...args: A) => R1, (...args: A) => R2]): (...args: A) => [R1, R2]
  • juxt<A, R1, R2, R3>(fns: [(...args: A) => R1, (...args: A) => R2, (...args: A) => R3]): (...args: A) => [R1, R2, R3]
  • juxt<A, R1, R2, R3, R4>(fns: [(...args: A) => R1, (...args: A) => R2, (...args: A) => R3, (...args: A) => R4]): (...args: A) => [R1, R2, R3, R4]
  • juxt<A, R1, R2, R3, R4, R5>(fns: [(...args: A) => R1, (...args: A) => R2, (...args: A) => R3, (...args: A) => R4, (...args: A) => R5]): (...args: A) => [R1, R2, R3, R4, R5]
  • juxt<A, U>(fns: readonly ((...args: A) => U)[]): (...args: A) => U[]
  • Applies a list of functions to a list of values.

    See also applySpec.

    example
    const getRange = R.juxt([Math.min, Math.max]);
    getRange(3, 4, 9, -3); //=> [-3, 9]

    Type parameters

    • A: any[]

    • R1

    Parameters

    • fns: [(...args: A) => R1]

    Returns (...args: A) => [R1]

      • (...args: A): [R1]
      • Applies a list of functions to a list of values.

        See also applySpec.

        example
        const getRange = R.juxt([Math.min, Math.max]);
        getRange(3, 4, 9, -3); //=> [-3, 9]

        Parameters

        • Rest ...args: A

        Returns [R1]

  • Type parameters

    • A: any[]

    • R1

    • R2

    Parameters

    • fns: [(...args: A) => R1, (...args: A) => R2]

    Returns (...args: A) => [R1, R2]

      • (...args: A): [R1, R2]
      • Parameters

        • Rest ...args: A

        Returns [R1, R2]

  • Type parameters

    • A: any[]

    • R1

    • R2

    • R3

    Parameters

    • fns: [(...args: A) => R1, (...args: A) => R2, (...args: A) => R3]

    Returns (...args: A) => [R1, R2, R3]

      • (...args: A): [R1, R2, R3]
      • Parameters

        • Rest ...args: A

        Returns [R1, R2, R3]

  • Type parameters

    • A: any[]

    • R1

    • R2

    • R3

    • R4

    Parameters

    • fns: [(...args: A) => R1, (...args: A) => R2, (...args: A) => R3, (...args: A) => R4]

    Returns (...args: A) => [R1, R2, R3, R4]

      • (...args: A): [R1, R2, R3, R4]
      • Parameters

        • Rest ...args: A

        Returns [R1, R2, R3, R4]

  • Type parameters

    • A: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    Parameters

    • fns: [(...args: A) => R1, (...args: A) => R2, (...args: A) => R3, (...args: A) => R4, (...args: A) => R5]

    Returns (...args: A) => [R1, R2, R3, R4, R5]

      • (...args: A): [R1, R2, R3, R4, R5]
      • Parameters

        • Rest ...args: A

        Returns [R1, R2, R3, R4, R5]

  • Type parameters

    • A: any[]

    • U

    Parameters

    • fns: readonly ((...args: A) => U)[]

    Returns (...args: A) => U[]

      • (...args: A): U[]
      • Parameters

        • Rest ...args: A

        Returns U[]

  • keys<T>(x: T): keyof T[]
  • keys<T>(x: T): string[]
  • Returns a list containing the names of all the enumerable own properties of the supplied object.

    note

    The order of the output array is not guaranteed to be consistent across different JS platforms.

    See also keysIn, values, toPairs.

    example
    R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
    

    Type parameters

    • T: object

    Parameters

    • x: T

    Returns keyof T[]

  • Type parameters

    • T

    Parameters

    • x: T

    Returns string[]

  • keysIn<T>(obj: T): string[]
  • Returns a list containing the names of all the properties of the supplied object, including prototype properties.

    note

    The order of the output array is not guaranteed to be consistent across different JS platforms.

    See also keys, valuesIn.

    example
    class F {
    y = 'Y';
    constructor(public x: string = 'X') {}
    }

    const f = new F();
    R.keysIn(f); //=> ['x', 'y']

    Type parameters

    • T

    Parameters

    • obj: T

    Returns string[]

  • last(str: string): string
  • last(list: readonly []): undefined
  • last<T>(list: readonly T[]): T | undefined
  • Returns the last element of the given list or string.

    See also init, head, tail.

    example
    R.last(['fi', 'fo', 'fum']); //=> 'fum'
    R.last([]); //=> undefined

    R.last('abc'); //=> 'c'
    R.last(''); //=> ''

    Parameters

    • str: string

    Returns string

  • Parameters

    • list: readonly []

    Returns undefined

  • Type parameters

    • T

    Parameters

    • list: readonly T[]

    Returns T | undefined

  • lastIndexOf(target: string, list: string | readonly string[]): number
  • lastIndexOf(target: string): (list: readonly string[] | string) => number
  • lastIndexOf<T>(target: T, list: readonly T[]): number
  • lastIndexOf<T>(target: T): (list: readonly T[]) => number
  • Returns the position of the last occurrence of an item in an array, or -1 if the item is not included in the array. R.equals is used to determine equality.

    example
    R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6
    R.lastIndexOf(10, [1,2,3,4]); //=> -1

    Parameters

    • target: string
    • list: string | readonly string[]

    Returns number

  • Parameters

    • target: string

    Returns (list: readonly string[] | string) => number

      • (list: readonly string[] | string): number
      • Parameters

        • list: readonly string[] | string

        Returns number

  • Type parameters

    • T

    Parameters

    • target: T
    • list: readonly T[]

    Returns number

  • Type parameters

    • T

    Parameters

    • target: T

    Returns (list: readonly T[]) => number

      • (list: readonly T[]): number
      • Parameters

        • list: readonly T[]

        Returns number

  • length<T>(list: T): number
  • Returns the number of elements in the array by returning list.length.

    example
    R.length([]); //=> 0
    R.length([1, 2, 3]); //=> 3

    Type parameters

    • T: ArrayLike<unknown, T>

    Parameters

    • list: T

    Returns number

  • lens<S, A>(getter: (s: S) => A, setter: (a: A, s: S) => S): Lens<S, A>
  • Returns a lens for the given getter and setter functions. The getter "gets" the value of the focus; the setter "sets" the value of the focus. The setter should not mutate the data structure.

    See also view, set, over, lensIndex, lensProp.

    Type parameters

    • S

    • A

    Parameters

    • getter: (s: S) => A
        • (s: S): A
        • Parameters

          • s: S

          Returns A

    • setter: (a: A, s: S) => S
        • (a: A, s: S): S
        • Parameters

          • a: A
          • s: S

          Returns S

    Returns Lens<S, A>

  • lensIndex<A>(n: number): Lens<A[], A>
  • lensIndex<A, N>(n: N): Lens<A, A[N]>
  • Returns a lens whose focus is the specified index.

    See also view, set, over, nth, lens.

    example
    const headLens = R.lensIndex<string>(0);

    R.view(headLens, ['a', 'b', 'c']); //=> 'a'
    R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c']
    R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c']

    Type parameters

    • A

    Parameters

    • n: number

    Returns Lens<A[], A>

  • Type parameters

    • A: any[]

    • N: number

    Parameters

    • n: N

    Returns Lens<A, A[N]>

  • lensPath<S, K0>(path: [K0]): Lens<S, S[K0]>
  • lensPath<S, K0, K1>(path: [K0, K1]): Lens<S, S[K0][K1]>
  • lensPath<S, K0, K1, K2>(path: [K0, K1, K2]): Lens<S, S[K0][K1][K2]>
  • lensPath<S, K0, K1, K2, K3>(path: [K0, K1, K2, K3]): Lens<S, S[K0][K1][K2][K3]>
  • lensPath<S, K0, K1, K2, K3, K4>(path: [K0, K1, K2, K3, K4]): Lens<S, S[K0][K1][K2][K3][K4]>
  • lensPath<S, K0, K1, K2, K3, K4, K5>(path: [K0, K1, K2, K3, K4, K5]): Lens<S, S[K0][K1][K2][K3][K4][K5]>
  • lensPath<S, A>(path: Path): Lens<S, A>
  • Returns a lens whose focus is the specified path.

    See also view, set, over, lens.

    example
    const xHeadYLens = R.lensPath<{ x: { y: number; z: number; }[]; }, 'x', 0, 'y'>(['x', 0, 'y']);

    R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
    //=> 2
    R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
    //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]}
    R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
    //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]}

    Type parameters

    • S

    • K0: string | number | symbol = keyof S

    Parameters

    • path: [K0]

    Returns Lens<S, S[K0]>

  • Type parameters

    • S

    • K0: string | number | symbol = keyof S

    • K1: string | number | symbol = keyof S[K0]

    Parameters

    • path: [K0, K1]

    Returns Lens<S, S[K0][K1]>

  • Type parameters

    • S

    • K0: string | number | symbol = keyof S

    • K1: string | number | symbol = keyof S[K0]

    • K2: string | number | symbol = keyof S[K0][K1]

    Parameters

    • path: [K0, K1, K2]

    Returns Lens<S, S[K0][K1][K2]>

  • Type parameters

    • S

    • K0: string | number | symbol = keyof S

    • K1: string | number | symbol = keyof S[K0]

    • K2: string | number | symbol = keyof S[K0][K1]

    • K3: string | number | symbol = keyof S[K0][K1][K2]

    Parameters

    • path: [K0, K1, K2, K3]

    Returns Lens<S, S[K0][K1][K2][K3]>

  • Type parameters

    • S

    • K0: string | number | symbol = keyof S

    • K1: string | number | symbol = keyof S[K0]

    • K2: string | number | symbol = keyof S[K0][K1]

    • K3: string | number | symbol = keyof S[K0][K1][K2]

    • K4: string | number | symbol = keyof S[K0][K1][K2][K3]

    Parameters

    • path: [K0, K1, K2, K3, K4]

    Returns Lens<S, S[K0][K1][K2][K3][K4]>

  • Type parameters

    • S

    • K0: string | number | symbol = keyof S

    • K1: string | number | symbol = keyof S[K0]

    • K2: string | number | symbol = keyof S[K0][K1]

    • K3: string | number | symbol = keyof S[K0][K1][K2]

    • K4: string | number | symbol = keyof S[K0][K1][K2][K3]

    • K5: string | number | symbol = keyof S[K0][K1][K2][K3][K4]

    Parameters

    • path: [K0, K1, K2, K3, K4, K5]

    Returns Lens<S, S[K0][K1][K2][K3][K4][K5]>

  • Type parameters

    • S = any

    • A = any

    Parameters

    Returns Lens<S, A>

  • lensProp<S, K>(prop: K): Lens<S, S[K]>
  • Returns a lens whose focus is the specified property.

    See also view, set, over, lens.

    example
    type Point = { x: number; y: number; };

    const xLens = R.lensProp<Point, 'x'>('x');

    R.view(xLens, {x: 1, y: 2}); //=> 1
    R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
    R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2}

    Type parameters

    • S

    • K: string | number | symbol = keyof S

    Parameters

    • prop: K

    Returns Lens<S, S[K]>

  • lift<F>(fn: F): { (...args: ToTupleOfArray<Parameters<F>>): ReturnType<F>[]; <R>(...args: ToTupleOfFunction<R, Parameters<F>>): (arg: R) => ReturnType<F> }
  • "lifts" a function of arity > 1 so that it may "map over" a list, Function or other object that satisfies the FantasyLand Apply spec.

    See also liftN.

    example
    const madd3 = R.lift((a: number, b: number, c: number) => a + b + c);

    madd3([100, 200], [30, 40], [5, 6, 7]); //=> [135, 136, 137, 145, 146, 147, 235, 236, 237, 245, 246, 247]

    const madd5 = R.lift((a: number, b: number, c: number, d: number, e: number) => a + b + c + d + e);

    madd5([10, 20], [1], [2, 3], [4], [100, 200]); //=> [117, 217, 118, 218, 127, 227, 128, 228]

    Type parameters

    Parameters

    • fn: F

    Returns { (...args: ToTupleOfArray<Parameters<F>>): ReturnType<F>[]; <R>(...args: ToTupleOfFunction<R, Parameters<F>>): (arg: R) => ReturnType<F> }

      • Parameters

        Returns ReturnType<F>[]

      • Type parameters

        • R

        Parameters

        Returns (arg: R) => ReturnType<F>

          • (arg: R): ReturnType<F>
          • Parameters

            • arg: R

            Returns ReturnType<F>

  • "lifts" a function to be the specified arity, so that it may "map over" that many lists, Functions or other objects that satisfy the FantasyLand Apply spec.

    See also lift, ap.

    example
    const madd3 = R.liftN(3, (...args: [number, number, number]) => R.sum(args));
    madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]

    Type parameters

    Parameters

    • n: N
    • fn: F

    Returns { (...args: Take<N, ToTupleOfArray<Parameters<F>>, []>): ReturnType<F>[]; <R>(...args: Take<N, ToTupleOfFunction<R, Parameters<F>>, []>): (arg: R) => ReturnType<F> }

      • Parameters

        Returns ReturnType<F>[]

      • Type parameters

        • R

        Parameters

        Returns (arg: R) => ReturnType<F>

          • (arg: R): ReturnType<F>
          • Parameters

            • arg: R

            Returns ReturnType<F>

  • lt(__: Placeholder, b: number): (a: number) => boolean
  • lt(__: Placeholder): (b: number, a: number) => boolean
  • lt(a: number, b: number): boolean
  • lt(a: string, b: string): boolean
  • lt(a: number): (b: number) => boolean
  • Returns true if the first parameter is less than the second; false otherwise.

    See also gt, gte, lte.

    example
    R.lt(2, 1); //=> false
    R.lt(2, 2); //=> false
    R.lt(2, 3); //=> true
    R.lt('a', 'z'); //=> true
    R.lt('z', 'a'); //=> false

    Parameters

    Returns (a: number) => boolean

      • (a: number): boolean
      • Returns true if the first parameter is less than the second; false otherwise.

        See also gt, gte, lte.

        example
        R.lt(2, 1); //=> false
        R.lt(2, 2); //=> false
        R.lt(2, 3); //=> true
        R.lt('a', 'z'); //=> true
        R.lt('z', 'a'); //=> false

        Parameters

        • a: number

        Returns boolean

  • Parameters

    Returns (b: number, a: number) => boolean

      • (b: number, a: number): boolean
      • Parameters

        • b: number
        • a: number

        Returns boolean

  • Parameters

    • a: number
    • b: number

    Returns boolean

  • Parameters

    • a: string
    • b: string

    Returns boolean

  • Parameters

    • a: number

    Returns (b: number) => boolean

      • (b: number): boolean
      • Parameters

        • b: number

        Returns boolean

  • lte(__: Placeholder, b: number): (a: number) => boolean
  • lte(__: Placeholder): (b: number, a: number) => boolean
  • lte(a: number, b: number): boolean
  • lte(a: string, b: string): boolean
  • lte(a: number): (b: number) => boolean
  • Returns true if the first parameter is less than or equal to the second; false otherwise.

    See also gt, gte, lt.

    example
    R.lte(2, 1); //=> false
    R.lte(2, 2); //=> true
    R.lte(2, 3); //=> true
    R.lte('a', 'z'); //=> true
    R.lte('z', 'a'); //=> false

    Parameters

    Returns (a: number) => boolean

      • (a: number): boolean
      • Returns true if the first parameter is less than or equal to the second; false otherwise.

        See also gt, gte, lt.

        example
        R.lte(2, 1); //=> false
        R.lte(2, 2); //=> true
        R.lte(2, 3); //=> true
        R.lte('a', 'z'); //=> true
        R.lte('z', 'a'); //=> false

        Parameters

        • a: number

        Returns boolean

  • Parameters

    Returns (b: number, a: number) => boolean

      • (b: number, a: number): boolean
      • Parameters

        • b: number
        • a: number

        Returns boolean

  • Parameters

    • a: number
    • b: number

    Returns boolean

  • Parameters

    • a: string
    • b: string

    Returns boolean

  • Parameters

    • a: number

    Returns (b: number) => boolean

      • (b: number): boolean
      • Parameters

        • b: number

        Returns boolean

  • map<T, U>(fn: (x: T) => U, list: readonly T[]): U[]
  • map<T, U>(fn: (x: T) => U): (list: readonly T[]) => U[]
  • map<T, U>(fn: (x: T[keyof T & keyof U] | ValueOfUnion<T>) => U[keyof T & keyof U], list: T): U
  • map<T, U>(fn: (x: T[keyof T & keyof U] | ValueOfUnion<T>) => U[keyof T & keyof U]): (list: T) => U
  • map<T, U>(fn: (x: T) => U, obj: Functor<T>): Functor<U>
  • map<T, U>(fn: (x: T) => U): (obj: Functor<T>) => Functor<U>
  • Takes a function and a functor, applies the function to each of the functor's values, and returns a functor of the same shape.

    Ramda provides suitable map implementations for Array and Object, so this function may be applied to [1, 2, 3] or {x: 1, y: 2, z: 3}.

    Dispatches to the map method of the second argument, if present.

    Acts as a transducer if a transformer is given in list position.

    Also treats functions as functors and will compose them together.

    See also addIndex, pluck, project, transduce.

    example
    const double = x => x * 2;

    R.map(double, [1, 2, 3]); //=> [2, 4, 6]

    R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6}

    Type parameters

    • T

    • U

    Parameters

    • fn: (x: T) => U
        • (x: T): U
        • Parameters

          • x: T

          Returns U

    • list: readonly T[]

    Returns U[]

  • Type parameters

    • T

    • U

    Parameters

    • fn: (x: T) => U
        • (x: T): U
        • Parameters

          • x: T

          Returns U

    Returns (list: readonly T[]) => U[]

      • (list: readonly T[]): U[]
      • Parameters

        • list: readonly T[]

        Returns U[]

  • Type parameters

    • T

    • U

    Parameters

    • fn: (x: T[keyof T & keyof U] | ValueOfUnion<T>) => U[keyof T & keyof U]
        • (x: T[keyof T & keyof U] | ValueOfUnion<T>): U[keyof T & keyof U]
        • Parameters

          Returns U[keyof T & keyof U]

    • list: T

    Returns U

  • Type parameters

    • T

    • U

    Parameters

    • fn: (x: T[keyof T & keyof U] | ValueOfUnion<T>) => U[keyof T & keyof U]
        • (x: T[keyof T & keyof U] | ValueOfUnion<T>): U[keyof T & keyof U]
        • Parameters

          Returns U[keyof T & keyof U]

    Returns (list: T) => U

      • (list: T): U
      • Parameters

        • list: T

        Returns U

  • Type parameters

    • T

    • U

    Parameters

    • fn: (x: T) => U
        • (x: T): U
        • Parameters

          • x: T

          Returns U

    • obj: Functor<T>

    Returns Functor<U>

  • Type parameters

    • T

    • U

    Parameters

    • fn: (x: T) => U
        • (x: T): U
        • Parameters

          • x: T

          Returns U

    Returns (obj: Functor<T>) => Functor<U>

  • mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U, list: readonly T[]): [U, TResult[]]
  • mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: readonly T[]) => [U, TResult[]]
  • mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: readonly T[]) => [U, TResult[]]
  • The mapAccum function behaves like a combination of map and reduce; it applies a function to each element of a list, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new list.

    The iterator function receives two arguments, acc and value, and should return a tuple [acc, value].

    See also scan, addIndex, mapAccumRight.

    example
    const digits = ['1', '2', '3', '4'];
    const appender = (a: string, b: string) => [a + b, a + b] as const;

    R.mapAccum(appender, '0', digits); //=> ['01234', ['01', '012', '0123', '01234']]

    Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (acc: U, value: T) => [U, TResult]
        • (acc: U, value: T): [U, TResult]
        • Parameters

          • acc: U
          • value: T

          Returns [U, TResult]

    • acc: U
    • list: readonly T[]

    Returns [U, TResult[]]

  • Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (acc: U, value: T) => [U, TResult]
        • (acc: U, value: T): [U, TResult]
        • Parameters

          • acc: U
          • value: T

          Returns [U, TResult]

    Returns (acc: U, list: readonly T[]) => [U, TResult[]]

      • (acc: U, list: readonly T[]): [U, TResult[]]
      • Parameters

        • acc: U
        • list: readonly T[]

        Returns [U, TResult[]]

  • Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (acc: U, value: T) => [U, TResult]
        • (acc: U, value: T): [U, TResult]
        • Parameters

          • acc: U
          • value: T

          Returns [U, TResult]

    • acc: U

    Returns (list: readonly T[]) => [U, TResult[]]

      • (list: readonly T[]): [U, TResult[]]
      • Parameters

        • list: readonly T[]

        Returns [U, TResult[]]

  • mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U, list: readonly T[]): [U, TResult[]]
  • mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: readonly T[]) => [U, TResult[]]
  • mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: readonly T[]) => [U, TResult[]]
  • Applies a function to each element of a list, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new list.

    Similar to R.mapAccum, except moves through the input list from the right to the left.

    The iterator function receives two arguments, acc and value, and should return a tuple [acc, value].

    See also addIndex, mapAccum.

    example
    const digits = ['1', '2', '3', '4'];
    const appender = (a: string, b: string) => [b + a, b + a] as const;

    R.mapAccumRight(appender, '5', digits); //=> ['12345', ['12345', '2345', '345', '45']]

    Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (acc: U, value: T) => [U, TResult]
        • (acc: U, value: T): [U, TResult]
        • Parameters

          • acc: U
          • value: T

          Returns [U, TResult]

    • acc: U
    • list: readonly T[]

    Returns [U, TResult[]]

  • Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (acc: U, value: T) => [U, TResult]
        • (acc: U, value: T): [U, TResult]
        • Parameters

          • acc: U
          • value: T

          Returns [U, TResult]

    Returns (acc: U, list: readonly T[]) => [U, TResult[]]

      • (acc: U, list: readonly T[]): [U, TResult[]]
      • Parameters

        • acc: U
        • list: readonly T[]

        Returns [U, TResult[]]

  • Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (acc: U, value: T) => [U, TResult]
        • (acc: U, value: T): [U, TResult]
        • Parameters

          • acc: U
          • value: T

          Returns [U, TResult]

    • acc: U

    Returns (list: readonly T[]) => [U, TResult[]]

      • (list: readonly T[]): [U, TResult[]]
      • Parameters

        • list: readonly T[]

        Returns [U, TResult[]]

  • mapObjIndexed<T, TResult, TKey>(fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult, obj: Record<TKey, T>): Record<TKey, TResult>
  • mapObjIndexed<T, TResult, TKey>(fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult, obj: PartialRecord<TKey, T>): PartialRecord<TKey, TResult>
  • mapObjIndexed<T, TResult, TKey>(fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult): (obj: Record<TKey, T>) => Record<TKey, TResult>
  • mapObjIndexed<T, TResult, TKey>(fn: (value: T, key: TKey, obj?: PartialRecord<TKey, T>) => TResult): (obj: Record<TKey, T>) => PartialRecord<TKey, TResult>
  • mapObjIndexed<T, TResult>(fn: (value: T, key: string, obj?: {}) => TResult, obj: {}): {}
  • Type parameters

    • T

    • TResult

    • TKey: string

    Parameters

    • fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult
        • (value: T, key: TKey, obj?: Record<TKey, T>): TResult
        • Parameters

          • value: T
          • key: TKey
          • Optional obj: Record<TKey, T>

          Returns TResult

    • obj: Record<TKey, T>

    Returns Record<TKey, TResult>

  • Type parameters

    • T

    • TResult

    • TKey: string

    Parameters

    • fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult
        • (value: T, key: TKey, obj?: Record<TKey, T>): TResult
        • Parameters

          • value: T
          • key: TKey
          • Optional obj: Record<TKey, T>

          Returns TResult

    • obj: PartialRecord<TKey, T>

    Returns PartialRecord<TKey, TResult>

  • Type parameters

    • T

    • TResult

    • TKey: string

    Parameters

    • fn: (value: T, key: TKey, obj?: Record<TKey, T>) => TResult
        • (value: T, key: TKey, obj?: Record<TKey, T>): TResult
        • Parameters

          • value: T
          • key: TKey
          • Optional obj: Record<TKey, T>

          Returns TResult

    Returns (obj: Record<TKey, T>) => Record<TKey, TResult>

      • (obj: Record<TKey, T>): Record<TKey, TResult>
      • Parameters

        • obj: Record<TKey, T>

        Returns Record<TKey, TResult>

  • Type parameters

    • T

    • TResult

    • TKey: string

    Parameters

    • fn: (value: T, key: TKey, obj?: PartialRecord<TKey, T>) => TResult
        • (value: T, key: TKey, obj?: PartialRecord<TKey, T>): TResult
        • Parameters

          • value: T
          • key: TKey
          • Optional obj: PartialRecord<TKey, T>

          Returns TResult

    Returns (obj: Record<TKey, T>) => PartialRecord<TKey, TResult>

      • (obj: Record<TKey, T>): PartialRecord<TKey, TResult>
      • Parameters

        • obj: Record<TKey, T>

        Returns PartialRecord<TKey, TResult>

  • Type parameters

    • T

    • TResult

    Parameters

    • fn: (value: T, key: string, obj?: {}) => TResult
        • (value: T, key: string, obj?: {}): TResult
        • Parameters

          • value: T
          • key: string
          • Optional obj: {}
            • [key: string]: T

          Returns TResult

    • obj: {}
      • [key: string]: T

    Returns {}

    • [key: string]: TResult
  • match(regexp: RegExp, str: string): string[]
  • match(regexp: RegExp): (str: string) => string[]
  • Tests a RegExp against a String.

    note

    This function will return an empty array when there are no matches. This differs from String.prototype.match which returns null when there are no matches.

    example
    R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na']
    R.match(/a/, 'b'); //=> []

    Parameters

    • regexp: RegExp
    • str: string

    Returns string[]

  • Parameters

    • regexp: RegExp

    Returns (str: string) => string[]

      • (str: string): string[]
      • Parameters

        • str: string

        Returns string[]

  • mathMod(__: Placeholder, b: number): (a: number) => number
  • mathMod(__: Placeholder): (b: number, a: number) => number
  • mathMod(a: number, b: number): number
  • mathMod(a: number): (b: number) => number
  • mathMod behaves like the modulo operator should mathematically, unlike the % operator (and by extension, R.modulo). So while -17 % 5 is -2, mathMod(-17, 5) is 3. mathMod requires integer arguments, and returns NaN when the modulus is zero or negative.

    See also modulo.

    example
    R.mathMod(-17, 5);  //=> 3
    R.mathMod(17, 5); //=> 2
    R.mathMod(17, -5); //=> NaN
    R.mathMod(17, 0); //=> NaN
    R.mathMod(17.2, 5); //=> NaN
    R.mathMod(17, 5.3); //=> NaN

    const clock = R.mathMod(R.__, 12);
    clock(15); //=> 3
    clock(24); //=> 0

    const seventeenMod = R.mathMod(17);
    seventeenMod(3); //=> 2
    seventeenMod(4); //=> 1
    seventeenMod(10); //=> 7

    Parameters

    Returns (a: number) => number

      • (a: number): number
      • mathMod behaves like the modulo operator should mathematically, unlike the % operator (and by extension, R.modulo). So while -17 % 5 is -2, mathMod(-17, 5) is 3. mathMod requires integer arguments, and returns NaN when the modulus is zero or negative.

        See also modulo.

        example
        R.mathMod(-17, 5);  //=> 3
        R.mathMod(17, 5); //=> 2
        R.mathMod(17, -5); //=> NaN
        R.mathMod(17, 0); //=> NaN
        R.mathMod(17.2, 5); //=> NaN
        R.mathMod(17, 5.3); //=> NaN

        const clock = R.mathMod(R.__, 12);
        clock(15); //=> 3
        clock(24); //=> 0

        const seventeenMod = R.mathMod(17);
        seventeenMod(3); //=> 2
        seventeenMod(4); //=> 1
        seventeenMod(10); //=> 7

        Parameters

        • a: number

        Returns number

  • Parameters

    Returns (b: number, a: number) => number

      • (b: number, a: number): number
      • Parameters

        • b: number
        • a: number

        Returns number

  • Parameters

    • a: number
    • b: number

    Returns number

  • Parameters

    • a: number

    Returns (b: number) => number

      • (b: number): number
      • Parameters

        • b: number

        Returns number

  • max<T>(a: T, b: T): T
  • max<T>(a: T): (b: T) => T
  • Returns the larger of its two arguments.

    See also maxBy, min, minBy.

    example
    R.max(789, 123); //=> 789
    R.max('a', 'b'); //=> 'b'

    Type parameters

    Parameters

    • a: T
    • b: T

    Returns T

  • Type parameters

    Parameters

    • a: T

    Returns (b: T) => T

      • (b: T): T
      • Parameters

        • b: T

        Returns T

  • maxBy<T>(keyFn: (a: T) => Ord, a: T, b: T): T
  • maxBy<T>(keyFn: (a: T) => Ord, a: T): (b: T) => T
  • maxBy<T>(keyFn: (a: T) => Ord): _.F.Curry<(a: T, b: T) => T>
  • Takes a function and two values, and returns whichever value produces the larger result when passed to the provided function.

    See also max, min, minBy.

    example
    //  square :: Number -> Number
    const square = (n: number) => n * n;

    R.maxBy(square, -3, 2); //=> -3

    R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5
    R.reduce(R.maxBy(square), 0, [] as number[]); //=> 0

    Type parameters

    • T

    Parameters

    • keyFn: (a: T) => Ord
        • Parameters

          • a: T

          Returns Ord

    • a: T
    • b: T

    Returns T

  • Type parameters

    • T

    Parameters

    • keyFn: (a: T) => Ord
        • Parameters

          • a: T

          Returns Ord

    • a: T

    Returns (b: T) => T

      • (b: T): T
      • Parameters

        • b: T

        Returns T

  • Type parameters

    • T

    Parameters

    • keyFn: (a: T) => Ord
        • Parameters

          • a: T

          Returns Ord

    Returns _.F.Curry<(a: T, b: T) => T>

  • mean(list: readonly number[]): number
  • Returns the mean of the given list of numbers.

    See also median.

    example
    R.mean([2, 7, 9]); //=> 6
    R.mean([]); //=> NaN

    Parameters

    • list: readonly number[]

    Returns number

  • median(list: readonly number[]): number
  • Returns the median of the given list of numbers.

    See also mean.

    example
    R.median([2, 9, 7]); //=> 7
    R.median([7, 2, 10, 9]); //=> 8
    R.median([]); //=> NaN

    Parameters

    • list: readonly number[]

    Returns number

  • memoizeWith<T>(keyFn: (...v: Parameters<T>) => string, fn: T): T
  • Creates a new function that, when invoked, caches the result of calling the given function for a given argument set and returns the result. Subsequent calls to the memoized function with the same argument set will return the cached result.

    example
    let count = 0;
    const factorial = R.memoizeWith(String, (n: number) => {
    count += 1;
    return R.product(R.range(1, n + 1));
    });
    factorial(5); //=> 120
    factorial(5); //=> 120
    factorial(5); //=> 120
    count; //=> 1

    Type parameters

    Parameters

    • keyFn: (...v: Parameters<T>) => string
        • (...v: Parameters<T>): string
        • Parameters

          • Rest ...v: Parameters<T>

          Returns string

    • fn: T

    Returns T

  • merge<O2>(__: Placeholder, b: O2): <O1>(a: O1) => Merge<O2, O1, "flat">
  • merge(__: Placeholder): <O1, O2>(b: O2, a: O1) => Merge<O2, O1, "flat">
  • merge<O1, O2>(a: O1, b: O2): Merge<O2, O1, "flat">
  • merge<O1>(a: O1): <O2>(b: O2) => Merge<O2, O1, "flat">
  • Create a new object with the own properties of a merged with the own properties of object b. This function will not mutate passed-in objects.

    deprecated

    since 0.26 in favor of mergeRight

    Type parameters

    • O2: object

    Parameters

    Returns <O1>(a: O1) => Merge<O2, O1, "flat">

      • <O1>(a: O1): Merge<O2, O1, "flat">
      • Create a new object with the own properties of a merged with the own properties of object b. This function will not mutate passed-in objects.

        deprecated

        since 0.26 in favor of mergeRight

        Type parameters

        • O1: object

        Parameters

        • a: O1

        Returns Merge<O2, O1, "flat">

  • Parameters

    Returns <O1, O2>(b: O2, a: O1) => Merge<O2, O1, "flat">

      • <O1, O2>(b: O2, a: O1): Merge<O2, O1, "flat">
      • Type parameters

        • O1: object

        • O2: object

        Parameters

        • b: O2
        • a: O1

        Returns Merge<O2, O1, "flat">

  • Type parameters

    • O1: object

    • O2: object

    Parameters

    • a: O1
    • b: O2

    Returns Merge<O2, O1, "flat">

  • Type parameters

    • O1: object

    Parameters

    • a: O1

    Returns <O2>(b: O2) => Merge<O2, O1, "flat">

      • <O2>(b: O2): Merge<O2, O1, "flat">
      • Type parameters

        • O2: object

        Parameters

        • b: O2

        Returns Merge<O2, O1, "flat">

  • Creates one new object with the own properties from a list of objects. If a key exists in more than one object, the value from the last object it exists in will be used.

    See also reduce.

    example
    R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3}
    R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2}

    Type parameters

    • Os: readonly object[]

    Parameters

    • list: Os

    Returns MergeAll<Os>

  • mergeDeepLeft<O1, O2>(o1: O1, o2: O2): Merge<O1, O2, "deep">
  • mergeDeepLeft<O1>(o1: O1): <O2>(o2: O2) => Merge<O1, O2, "deep">
  • Creates a new object with the own properties of the first object merged with the own properties of the second object.

    If a key exists in both objects:

    • and both values are objects, the two values will be recursively merged
    • otherwise the value from the first object will be used.

    See also mergeDeepRight, mergeDeepWith, mergeDeepWithKey.

    example
    R.mergeDeepLeft({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }},
    { age: 40, contact: { email: 'baa@example.com' }});
    //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }}

    Type parameters

    • O1: object

    • O2: object

    Parameters

    • o1: O1
    • o2: O2

    Returns Merge<O1, O2, "deep">

  • Type parameters

    • O1: object

    Parameters

    • o1: O1

    Returns <O2>(o2: O2) => Merge<O1, O2, "deep">

      • <O2>(o2: O2): Merge<O1, O2, "deep">
      • Type parameters

        • O2: object

        Parameters

        • o2: O2

        Returns Merge<O1, O2, "deep">

  • mergeDeepRight<O1, O2>(o1: O1, o2: O2): Merge<O2, O1, "deep">
  • mergeDeepRight<O1>(a: O1): <O2>(o2: O2) => Merge<O2, O1, "deep">
  • Creates a new object with the own properties of the first object merged with the own properties of the second object.

    If a key exists in both objects:

    • and both values are objects, the two values will be recursively merged
    • otherwise the value from the second object will be used.

    See also mergeDeepLeft, mergeDeepWith, mergeDeepWithKey.

    example
    R.mergeDeepRight({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }},
    { age: 40, contact: { email: 'baa@example.com' }});
    //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }}

    Type parameters

    • O1: object

    • O2: object

    Parameters

    • o1: O1
    • o2: O2

    Returns Merge<O2, O1, "deep">

  • Type parameters

    • O1: object

    Parameters

    • a: O1

    Returns <O2>(o2: O2) => Merge<O2, O1, "deep">

      • <O2>(o2: O2): Merge<O2, O1, "deep">
      • Type parameters

        • O2: object

        Parameters

        • o2: O2

        Returns Merge<O2, O1, "deep">

  • mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any, a: T1, b: T2): any
  • mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any, a: T1): (b: T2) => any
  • mergeDeepWith<T1, T2>(fn: (x: any, z: any) => any): (a: T1, b: T2) => any
  • Creates a new object with the own properties of the two provided objects.

    If a key exists in both objects:

    • and both associated values are also objects then the values will be recursively merged.
    • otherwise the provided function is applied to associated values using the resulting value as the new value associated with the key. If a key only exists in one object, the value will be associated with the key of the resulting object.

    See also mergeWith, mergeDeepWithKey.

    example
    R.mergeDeepWith(R.concat,
    { a: true, c: { values: [10, 20] }},
    { b: true, c: { values: [15, 35] }});
    //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }}

    Type parameters

    • T1

    • T2

    Parameters

    • fn: (x: any, z: any) => any
        • (x: any, z: any): any
        • Parameters

          • x: any
          • z: any

          Returns any

    • a: T1
    • b: T2

    Returns any

  • Type parameters

    • T1

    • T2

    Parameters

    • fn: (x: any, z: any) => any
        • (x: any, z: any): any
        • Parameters

          • x: any
          • z: any

          Returns any

    • a: T1

    Returns (b: T2) => any

      • (b: T2): any
      • Parameters

        • b: T2

        Returns any

  • Type parameters

    • T1

    • T2

    Parameters

    • fn: (x: any, z: any) => any
        • (x: any, z: any): any
        • Parameters

          • x: any
          • z: any

          Returns any

    Returns (a: T1, b: T2) => any

      • (a: T1, b: T2): any
      • Parameters

        • a: T1
        • b: T2

        Returns any

  • mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any, a: T1, b: T2): any
  • mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any, a: T1): (b: T2) => any
  • mergeDeepWithKey<T1, T2>(fn: (k: string, x: any, z: any) => any): (a: T1, b: T2) => any
  • Creates a new object with the own properties of the two provided objects. If a key exists in both objects: and both associated values are also objects then the values will be recursively merged. otherwise the provided function is applied to the key and associated values using the resulting value as the new value associated with the key. If a key only exists in one object, the value will be associated with the key of the resulting object.

    example
    let concatValues = <T>(k: string, l: T, r: T) => k == 'values' ? R.concat(l, r) : r
    R.mergeDeepWithKey(concatValues,
    { a: true, c: { thing: 'foo', values: [10, 20] }},
    { b: true, c: { thing: 'bar', values: [15, 35] }});
    //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }}

    Type parameters

    • T1

    • T2

    Parameters

    • fn: (k: string, x: any, z: any) => any
        • (k: string, x: any, z: any): any
        • Parameters

          • k: string
          • x: any
          • z: any

          Returns any

    • a: T1
    • b: T2

    Returns any

  • Type parameters

    • T1

    • T2

    Parameters

    • fn: (k: string, x: any, z: any) => any
        • (k: string, x: any, z: any): any
        • Parameters

          • k: string
          • x: any
          • z: any

          Returns any

    • a: T1

    Returns (b: T2) => any

      • (b: T2): any
      • Parameters

        • b: T2

        Returns any

  • Type parameters

    • T1

    • T2

    Parameters

    • fn: (k: string, x: any, z: any) => any
        • (k: string, x: any, z: any): any
        • Parameters

          • k: string
          • x: any
          • z: any

          Returns any

    Returns (a: T1, b: T2) => any

      • (a: T1, b: T2): any
      • Parameters

        • a: T1
        • b: T2

        Returns any

  • mergeLeft<O1, O2>(a: O1, b: O2): Merge<O1, O2, "flat">
  • mergeLeft<O1>(a: O1): <O2>(b: O2) => Merge<O1, O2, "flat">
  • Create a new object with the own properties of the first object merged with the own properties of the second object. If a key exists in both objects, the value from the first object will be used.

    example
    R.mergeLeft({ 'age': 40 }, { 'name': 'fred', 'age': 10 });
    //=> { 'name': 'fred', 'age': 40 }

    const resetToDefault = R.mergeLeft({x: 0});
    resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2}

    Type parameters

    • O1: object

    • O2: object

    Parameters

    • a: O1
    • b: O2

    Returns Merge<O1, O2, "flat">

  • Type parameters

    • O1: object

    Parameters

    • a: O1

    Returns <O2>(b: O2) => Merge<O1, O2, "flat">

      • <O2>(b: O2): Merge<O1, O2, "flat">
      • Type parameters

        • O2: object

        Parameters

        • b: O2

        Returns Merge<O1, O2, "flat">

  • mergeRight<O1, O2>(a: O1, b: O2): Merge<O2, O1, "flat">
  • mergeRight<O1>(a: O1): <O2>(b: O2) => Merge<O2, O1, "flat">
  • Create a new object with the own properties of the first object merged with the own properties of the second object. If a key exists in both objects, the value from the second object will be used.

    example
    R.mergeRight({ 'name': 'fred', 'age': 10 }, { 'age': 40 });
    //=> { 'name': 'fred', 'age': 40 }

    const withDefaults = R.mergeRight({x: 0, y: 0});
    withDefaults({y: 2}); //=> {x: 0, y: 2}

    Type parameters

    • O1: object

    • O2: object

    Parameters

    • a: O1
    • b: O2

    Returns Merge<O2, O1, "flat">

  • Type parameters

    • O1: object

    Parameters

    • a: O1

    Returns <O2>(b: O2) => Merge<O2, O1, "flat">

      • <O2>(b: O2): Merge<O2, O1, "flat">
      • Type parameters

        • O2: object

        Parameters

        • b: O2

        Returns Merge<O2, O1, "flat">

  • mergeWith<U, V>(fn: (x: any, z: any) => any, a: U, b: V): any
  • mergeWith<U>(fn: (x: any, z: any) => any, a: U): <V>(b: V) => any
  • mergeWith(fn: (x: any, z: any) => any): <U, V>(a: U, b: V) => any
  • Creates a new object with the own properties of the two provided objects. If a key exists in both objects, the provided function is applied to the values associated with the key in each object, with the result being used as the value associated with the key in the returned object. The key will be excluded from the returned object if the resulting value is undefined.

    example
    R.mergeWith(R.concat,
    { a: true, values: [10, 20] },
    { b: true, values: [15, 35] });
    //=> { a: true, b: true, values: [10, 20, 15, 35] }

    Type parameters

    • U

    • V

    Parameters

    • fn: (x: any, z: any) => any
        • (x: any, z: any): any
        • Parameters

          • x: any
          • z: any

          Returns any

    • a: U
    • b: V

    Returns any

  • Type parameters

    • U

    Parameters

    • fn: (x: any, z: any) => any
        • (x: any, z: any): any
        • Parameters

          • x: any
          • z: any

          Returns any

    • a: U

    Returns <V>(b: V) => any

      • <V>(b: V): any
      • Type parameters

        • V

        Parameters

        • b: V

        Returns any

  • Parameters

    • fn: (x: any, z: any) => any
        • (x: any, z: any): any
        • Parameters

          • x: any
          • z: any

          Returns any

    Returns <U, V>(a: U, b: V) => any

      • <U, V>(a: U, b: V): any
      • Type parameters

        • U

        • V

        Parameters

        • a: U
        • b: V

        Returns any

  • mergeWithKey<U, V>(fn: (str: string, x: any, z: any) => any, a: U, b: V): any
  • mergeWithKey<U>(fn: (str: string, x: any, z: any) => any, a: U): <V>(b: V) => any
  • mergeWithKey(fn: (str: string, x: any, z: any) => any): <U, V>(a: U, b: V) => any
  • Creates a new object with the own properties of the two provided objects. If a key exists in both objects, the provided function is applied to the key and the values associated with the key in each object, with the result being used as the value associated with the key in the returned object. The key will be excluded from the returned object if the resulting value is undefined.

    example
    let concatValues = <T>(k: string, l: T, r: T) => k == 'values' ? R.concat(l as any, r as any) : r
    R.mergeWithKey(concatValues,
    { a: true, thing: 'foo', values: [10, 20] },
    { b: true, thing: 'bar', values: [15, 35] });
    //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }

    Type parameters

    • U

    • V

    Parameters

    • fn: (str: string, x: any, z: any) => any
        • (str: string, x: any, z: any): any
        • Parameters

          • str: string
          • x: any
          • z: any

          Returns any

    • a: U
    • b: V

    Returns any

  • Type parameters

    • U

    Parameters

    • fn: (str: string, x: any, z: any) => any
        • (str: string, x: any, z: any): any
        • Parameters

          • str: string
          • x: any
          • z: any

          Returns any

    • a: U

    Returns <V>(b: V) => any

      • <V>(b: V): any
      • Type parameters

        • V

        Parameters

        • b: V

        Returns any

  • Parameters

    • fn: (str: string, x: any, z: any) => any
        • (str: string, x: any, z: any): any
        • Parameters

          • str: string
          • x: any
          • z: any

          Returns any

    Returns <U, V>(a: U, b: V) => any

      • <U, V>(a: U, b: V): any
      • Type parameters

        • U

        • V

        Parameters

        • a: U
        • b: V

        Returns any

  • min<T>(a: T, b: T): T
  • min<T>(a: T): (b: T) => T
  • Returns the smaller of its two arguments.

    See also minBy, max.

    example
    R.min(789, 123); //=> 123
    R.min('a', 'b'); //=> 'a'

    Type parameters

    Parameters

    • a: T
    • b: T

    Returns T

  • Type parameters

    Parameters

    • a: T

    Returns (b: T) => T

      • (b: T): T
      • Parameters

        • b: T

        Returns T

  • minBy<T>(keyFn: (a: T) => Ord, a: T, b: T): T
  • minBy<T>(keyFn: (a: T) => Ord, a: T): (b: T) => T
  • minBy<T>(keyFn: (a: T) => Ord): _.F.Curry<(a: T, b: T) => T>
  • Takes a function and two values, and returns whichever value produces the smaller result when passed to the provided function.

    See also min, maxBy.

    example
    //  square :: Number -> Number
    const square = (n: number) => n * n;

    R.minBy(square, -3, 2); //=> 2

    R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1
    R.reduce(R.minBy(square), Infinity, [] as number); //=> Infinity

    Type parameters

    • T

    Parameters

    • keyFn: (a: T) => Ord
        • Parameters

          • a: T

          Returns Ord

    • a: T
    • b: T

    Returns T

  • Type parameters

    • T

    Parameters

    • keyFn: (a: T) => Ord
        • Parameters

          • a: T

          Returns Ord

    • a: T

    Returns (b: T) => T

      • (b: T): T
      • Parameters

        • b: T

        Returns T

  • Type parameters

    • T

    Parameters

    • keyFn: (a: T) => Ord
        • Parameters

          • a: T

          Returns Ord

    Returns _.F.Curry<(a: T, b: T) => T>

  • modulo(__: Placeholder, b: number): (a: number) => number
  • modulo(__: Placeholder): (b: number, a: number) => number
  • modulo(a: number, b: number): number
  • modulo(a: number): (b: number) => number
  • Returns the modulo of two numbers. Equivalent to a % b but curried.

    Divides the first parameter by the second and returns the remainder. Note that this function preserves the JavaScript-style behavior for modulo. For mathematical modulo see R.mathMod.

    See also mathMod.

    example
    R.modulo(17, 3); //=> 2
    // JS behavior:
    R.modulo(-17, 3); //=> -2
    R.modulo(17, -3); //=> 2

    const isOdd = R.modulo(R.__, 2);
    isOdd(42); //=> 0
    isOdd(21); //=> 1

    Parameters

    Returns (a: number) => number

      • (a: number): number
      • Returns the modulo of two numbers. Equivalent to a % b but curried.

        Divides the first parameter by the second and returns the remainder. Note that this function preserves the JavaScript-style behavior for modulo. For mathematical modulo see R.mathMod.

        See also mathMod.

        example
        R.modulo(17, 3); //=> 2
        // JS behavior:
        R.modulo(-17, 3); //=> -2
        R.modulo(17, -3); //=> 2

        const isOdd = R.modulo(R.__, 2);
        isOdd(42); //=> 0
        isOdd(21); //=> 1

        Parameters

        • a: number

        Returns number

  • Parameters

    Returns (b: number, a: number) => number

      • (b: number, a: number): number
      • Parameters

        • b: number
        • a: number

        Returns number

  • Parameters

    • a: number
    • b: number

    Returns number

  • Parameters

    • a: number

    Returns (b: number) => number

      • (b: number): number
      • Parameters

        • b: number

        Returns number

  • move<T>(from: number, to: number, list: readonly T[]): T[]
  • move(from: number, to: number): <T>(list: readonly T[]) => T[]
  • move(from: number): { <T>(to: number, list: readonly T[]): T[]; (to: number): <T>(list: readonly T[]) => T[] }
  • Returns a copy of the given list with the item at the given source index moved to the given destination index.

    example
    R.move(0, 2, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['b', 'c', 'a', 'd', 'e', 'f']
    R.move(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'a', 'b', 'c', 'd', 'e'] list rotation

    Type parameters

    • T

    Parameters

    • from: number
    • to: number
    • list: readonly T[]

    Returns T[]

  • Parameters

    • from: number
    • to: number

    Returns <T>(list: readonly T[]) => T[]

      • <T>(list: readonly T[]): T[]
      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns T[]

  • Parameters

    • from: number

    Returns { <T>(to: number, list: readonly T[]): T[]; (to: number): <T>(list: readonly T[]) => T[] }

      • <T>(to: number, list: readonly T[]): T[]
      • (to: number): <T>(list: readonly T[]) => T[]
      • Type parameters

        • T

        Parameters

        • to: number
        • list: readonly T[]

        Returns T[]

      • Parameters

        • to: number

        Returns <T>(list: readonly T[]) => T[]

          • <T>(list: readonly T[]): T[]
          • Type parameters

            • T

            Parameters

            • list: readonly T[]

            Returns T[]

  • multiply(a: number, b: number): number
  • multiply(a: number): (b: number) => number
  • Multiplies two numbers. Equivalent to a * b but curried.

    See also divide.

    example
    const double = R.multiply(2);
    const triple = R.multiply(3);
    double(3); //=> 6
    triple(4); //=> 12
    R.multiply(2, 5); //=> 10

    Parameters

    • a: number
    • b: number

    Returns number

  • Parameters

    • a: number

    Returns (b: number) => number

      • (b: number): number
      • Parameters

        • b: number

        Returns number

  • nAry<N, T>(n: N, fn: T): (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>
  • nAry<N>(n: N): <T>(fn: T) => (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>
  • Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters. Any extraneous parameters will not be passed to the supplied function.

    See also binary, unary.

    example
    const takesTwoArgs = <T, U>(a: T, b: U) => [a, b];

    takesTwoArgs.length; //=> 2
    takesTwoArgs(1, 2); //=> [1, 2]

    const takesOneArg = R.nAry(1, takesTwoArgs);
    takesOneArg.length; //=> 1
    // Only `n` arguments are passed to the wrapped function
    takesOneArg(1); //=> [1, undefined]

    Type parameters

    Parameters

    • n: N
    • fn: T

    Returns (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>

      • (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>): ReturnType<T>
      • Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters. Any extraneous parameters will not be passed to the supplied function.

        See also binary, unary.

        example
        const takesTwoArgs = <T, U>(a: T, b: U) => [a, b];

        takesTwoArgs.length; //=> 2
        takesTwoArgs(1, 2); //=> [1, 2]

        const takesOneArg = R.nAry(1, takesTwoArgs);
        takesOneArg.length; //=> 1
        // Only `n` arguments are passed to the wrapped function
        takesOneArg(1); //=> [1, undefined]

        Parameters

        • Rest ...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>

        Returns ReturnType<T>

  • Type parameters

    • N: number

    Parameters

    • n: N

    Returns <T>(fn: T) => (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>

      • <T>(fn: T): (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>
      • Type parameters

        Parameters

        • fn: T

        Returns (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>) => ReturnType<T>

          • (...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>): ReturnType<T>
          • Parameters

            • Rest ...arg: _.T.Take<Parameters<T>, _.N.NumberOf<N>>

            Returns ReturnType<T>

  • negate(n: number): number
  • Negates its argument.

    example
    R.negate(42); //=> -42
    

    Parameters

    • n: number

    Returns number

  • none<T>(fn: (a: T) => boolean, list: readonly T[]): boolean
  • none<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean
  • Returns true if no elements of the list match the predicate, false otherwise.

    Dispatches to the all method of the second argument, if present.

    Acts as a transducer if a transformer is given in list position.

    See also all, any, transduce.

    example
    const isEven = (n: number) => n % 2 === 0;
    const isOdd = (n: number) => n % 2 !== 0;

    R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true
    R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false

    Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns boolean

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns (list: readonly T[]) => boolean

      • (list: readonly T[]): boolean
      • Parameters

        • list: readonly T[]

        Returns boolean

  • not(value: any): boolean
  • A function that returns the ! of its argument. It will return true when passed falsy value, and false when passed a truthy one.

    See also complement.

    example
    R.not(true); //=> false
    R.not(false); //=> true
    R.not(0); //=> true
    R.not(1); //=> false

    Parameters

    • value: any

    Returns boolean

  • nth<T>(n: number, list: readonly T[]): T | undefined
  • nth(n: number, list: string): string
  • nth(n: number): { <T>(list: readonly T[]): undefined | T; (list: string): string }
  • Returns the nth element of the given list or string.

    If n is negative the element at index length + n is returned.

    example
    const list = ['foo', 'bar', 'baz', 'quux'];
    R.nth(1, list); //=> 'bar'
    R.nth(-1, list); //=> 'quux'
    R.nth(-99, list); //=> undefined

    R.nth(2, 'abc'); //=> 'c'
    R.nth(3, 'abc'); //=> ''

    Type parameters

    • T

    Parameters

    • n: number
    • list: readonly T[]

    Returns T | undefined

  • Parameters

    • n: number
    • list: string

    Returns string

  • Parameters

    • n: number

    Returns { <T>(list: readonly T[]): undefined | T; (list: string): string }

      • <T>(list: readonly T[]): undefined | T
      • (list: string): string
      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns undefined | T

      • Parameters

        • list: string

        Returns string

  • nthArg(n: number): (...args: unknown[]) => unknown
  • Returns a function which returns its nth argument.

    example
    R.nthArg(1)('a', 'b', 'c');  //=> 'b'
    R.nthArg(-1)('a', 'b', 'c'); //=> 'c'

    Parameters

    • n: number

    Returns (...args: unknown[]) => unknown

      • (...args: unknown[]): unknown
      • Returns a function which returns its nth argument.

        example
        R.nthArg(1)('a', 'b', 'c');  //=> 'b'
        R.nthArg(-1)('a', 'b', 'c'); //=> 'c'

        Parameters

        • Rest ...args: unknown[]

        Returns unknown

  • o<T1, T2, R>(f: (x: T2) => R, g: (x: T1) => T2, v: T1): R
  • o<T1, T2, R>(f: (x: T2) => R, g: (x: T1) => T2): (v: T1) => R
  • o<T2, R>(f: (x: T2) => R): { <T1>(g: (x: T1) => T2, v: T1): R; <T1>(g: (x: T1) => T2): (v: T1) => R }
  • o is a curried composition function that returns a unary function. Like compose, o performs right-to-left function composition. Unlike compose, the rightmost function passed to o will be invoked with only one argument. Also, unlike compose, o is limited to accepting only 2 unary functions. The name o was chosen because of its similarity to the mathematical composition operator .

    See also compose, pipe.

    example
    type Name = { first: string; last: string; };

    const classyGreeting = (name: Name) => "The name's " + name.last + ", " + name.first + " " + name.last
    const yellGreeting = R.o(R.toUpper, classyGreeting);
    yellGreeting({first: 'James', last: 'Bond'}); //=> "THE NAME'S BOND, JAMES BOND"

    R.o(R.multiply(10), R.add(10))(-4) //=> 60

    Type parameters

    • T1

    • T2

    • R

    Parameters

    • f: (x: T2) => R
        • (x: T2): R
        • Parameters

          • x: T2

          Returns R

    • g: (x: T1) => T2
        • (x: T1): T2
        • Parameters

          • x: T1

          Returns T2

    • v: T1

    Returns R

  • Type parameters

    • T1

    • T2

    • R

    Parameters

    • f: (x: T2) => R
        • (x: T2): R
        • Parameters

          • x: T2

          Returns R

    • g: (x: T1) => T2
        • (x: T1): T2
        • Parameters

          • x: T1

          Returns T2

    Returns (v: T1) => R

      • (v: T1): R
      • Parameters

        • v: T1

        Returns R

  • Type parameters

    • T2

    • R

    Parameters

    • f: (x: T2) => R
        • (x: T2): R
        • Parameters

          • x: T2

          Returns R

    Returns { <T1>(g: (x: T1) => T2, v: T1): R; <T1>(g: (x: T1) => T2): (v: T1) => R }

      • <T1>(g: (x: T1) => T2, v: T1): R
      • <T1>(g: (x: T1) => T2): (v: T1) => R
      • Type parameters

        • T1

        Parameters

        • g: (x: T1) => T2
            • (x: T1): T2
            • Parameters

              • x: T1

              Returns T2

        • v: T1

        Returns R

      • Type parameters

        • T1

        Parameters

        • g: (x: T1) => T2
            • (x: T1): T2
            • Parameters

              • x: T1

              Returns T2

        Returns (v: T1) => R

          • (v: T1): R
          • Parameters

            • v: T1

            Returns R

  • objOf<T, K>(key: K, value: T): Record<K, T>
  • objOf<K>(key: K): <T>(value: T) => Record<K, T>
  • Creates an object containing a single key:value pair.

    See also pair.

    example
    const matchPhrases = R.compose(
    R.objOf('must'),
    R.map(R.objOf('match_phrase'))
    );
    matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]}

    Type parameters

    • T

    • K: string

    Parameters

    • key: K
    • value: T

    Returns Record<K, T>

  • Type parameters

    • K: string

    Parameters

    • key: K

    Returns <T>(value: T) => Record<K, T>

      • <T>(value: T): Record<K, T>
      • Type parameters

        • T

        Parameters

        • value: T

        Returns Record<K, T>

  • of<T>(x: T): T[]
  • Returns a singleton array containing the value provided.

    note

    This of is different from the ES6 Array.of.

    example
    R.of(null); //=> [null]
    R.of([42]); //=> <a href="common.web3.uniswap_sdk.html#WETH.__type.42">42</a>

    Type parameters

    • T

    Parameters

    • x: T

    Returns T[]

  • omit<T, K>(names: readonly K[], obj: T): Omit<T, K>
  • omit<K>(names: readonly K[]): <T>(obj: T) => Omit<T, K>
  • Returns a partial copy of an object omitting the keys specified.

    See also pick.

    example
    R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3}
    

    Type parameters

    • T

    • K: string

    Parameters

    • names: readonly K[]
    • obj: T

    Returns Omit<T, K>

  • Type parameters

    • K: string

    Parameters

    • names: readonly K[]

    Returns <T>(obj: T) => Omit<T, K>

      • <T>(obj: T): Omit<T, K>
      • Type parameters

        • T

        Parameters

        • obj: T

        Returns Omit<T, K>

  • on<T, U, R>(combine: (a: U, b: U) => R, transform: (value: T) => U, a: T, b: T): R
  • on<T, U, R>(combine: (a: U, b: U) => R, transform: (value: T) => U, a: T): (b: T) => R
  • on<T, U, R>(combine: (a: U, b: U) => R, transform: (value: T) => U): { (a: T, b: T): R; (a: T): (b: T) => R }
  • on<U, R>(combine: (a: U, b: U) => R): { <T>(transform: (value: T) => U, a: T, b: T): R; <T>(transform: (value: T) => U, a: T): (b: T) => R; <T>(transform: (value: T) => U): { (a: T, b: T): R; (a: T): (b: T) => R } }
  • on<T, U, R>(combine: (a: U, b: U) => R): { (transform: (value: T) => U, a: T, b: T): R; (transform: (value: T) => U, a: T): (b: T) => R; (transform: (value: T) => U): { (a: T, b: T): R; (a: T): (b: T) => R } }
  • Takes a binary function f, a unary function g, and two values. Applies g to each value, then applies the result of each to f. Also known as the P combinator.

    example
    const eqBy = R.on((a, b) => a === b);
    eqBy(R.prop('a'), {b:0, a:1}, {a:1}) //=> true;

    const containsInsensitive = R.on(R.contains, R.toLower);
    containsInsensitive('o', 'FOO'); //=> true

    Type parameters

    • T

    • U

    • R

    Parameters

    • combine: (a: U, b: U) => R
        • (a: U, b: U): R
        • Parameters

          • a: U
          • b: U

          Returns R

    • transform: (value: T) => U
        • (value: T): U
        • Parameters

          • value: T

          Returns U

    • a: T
    • b: T

    Returns R

  • Type parameters

    • T

    • U

    • R

    Parameters

    • combine: (a: U, b: U) => R
        • (a: U, b: U): R
        • Parameters

          • a: U
          • b: U

          Returns R

    • transform: (value: T) => U
        • (value: T): U
        • Parameters

          • value: T

          Returns U

    • a: T

    Returns (b: T) => R

      • (b: T): R
      • Parameters

        • b: T

        Returns R

  • Type parameters

    • T

    • U

    • R

    Parameters

    • combine: (a: U, b: U) => R
        • (a: U, b: U): R
        • Parameters

          • a: U
          • b: U

          Returns R

    • transform: (value: T) => U
        • (value: T): U
        • Parameters

          • value: T

          Returns U

    Returns { (a: T, b: T): R; (a: T): (b: T) => R }

      • (a: T, b: T): R
      • (a: T): (b: T) => R
      • Parameters

        • a: T
        • b: T

        Returns R

      • Parameters

        • a: T

        Returns (b: T) => R

          • (b: T): R
          • Parameters

            • b: T

            Returns R

  • Type parameters

    • U

    • R

    Parameters

    • combine: (a: U, b: U) => R
        • (a: U, b: U): R
        • Parameters

          • a: U
          • b: U

          Returns R

    Returns { <T>(transform: (value: T) => U, a: T, b: T): R; <T>(transform: (value: T) => U, a: T): (b: T) => R; <T>(transform: (value: T) => U): { (a: T, b: T): R; (a: T): (b: T) => R } }

      • <T>(transform: (value: T) => U, a: T, b: T): R
      • <T>(transform: (value: T) => U, a: T): (b: T) => R
      • <T>(transform: (value: T) => U): { (a: T, b: T): R; (a: T): (b: T) => R }
      • Type parameters

        • T

        Parameters

        • transform: (value: T) => U
            • (value: T): U
            • Parameters

              • value: T

              Returns U

        • a: T
        • b: T

        Returns R

      • Type parameters

        • T

        Parameters

        • transform: (value: T) => U
            • (value: T): U
            • Parameters

              • value: T

              Returns U

        • a: T

        Returns (b: T) => R

          • (b: T): R
          • Parameters

            • b: T

            Returns R

      • Type parameters

        • T

        Parameters

        • transform: (value: T) => U
            • (value: T): U
            • Parameters

              • value: T

              Returns U

        Returns { (a: T, b: T): R; (a: T): (b: T) => R }

          • (a: T, b: T): R
          • (a: T): (b: T) => R
          • Parameters

            • a: T
            • b: T

            Returns R

          • Parameters

            • a: T

            Returns (b: T) => R

              • (b: T): R
              • Parameters

                • b: T

                Returns R

  • Type parameters

    • T

    • U

    • R

    Parameters

    • combine: (a: U, b: U) => R
        • (a: U, b: U): R
        • Parameters

          • a: U
          • b: U

          Returns R

    Returns { (transform: (value: T) => U, a: T, b: T): R; (transform: (value: T) => U, a: T): (b: T) => R; (transform: (value: T) => U): { (a: T, b: T): R; (a: T): (b: T) => R } }

      • (transform: (value: T) => U, a: T, b: T): R
      • (transform: (value: T) => U, a: T): (b: T) => R
      • (transform: (value: T) => U): { (a: T, b: T): R; (a: T): (b: T) => R }
      • Parameters

        • transform: (value: T) => U
            • (value: T): U
            • Parameters

              • value: T

              Returns U

        • a: T
        • b: T

        Returns R

      • Parameters

        • transform: (value: T) => U
            • (value: T): U
            • Parameters

              • value: T

              Returns U

        • a: T

        Returns (b: T) => R

          • (b: T): R
          • Parameters

            • b: T

            Returns R

      • Parameters

        • transform: (value: T) => U
            • (value: T): U
            • Parameters

              • value: T

              Returns U

        Returns { (a: T, b: T): R; (a: T): (b: T) => R }

          • (a: T, b: T): R
          • (a: T): (b: T) => R
          • Parameters

            • a: T
            • b: T

            Returns R

          • Parameters

            • a: T

            Returns (b: T) => R

              • (b: T): R
              • Parameters

                • b: T

                Returns R

  • once<F>(fn: F): F
  • Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be called once, no matter how many times the returned function is invoked. The first value calculated is returned in subsequent invocations.

    example
    const addOneOnce = R.once((x: number) => x + 1);
    addOneOnce(10); //=> 11
    addOneOnce(addOneOnce(50)); //=> 11

    Type parameters

    Parameters

    • fn: F

    Returns F

  • or<T, U>(a: T | Falsy, b: U): T | U
  • or<T>(a: T | Falsy): <U>(b: U) => T | U
  • Returns the first argument if it is truthy, otherwise the second argument.

    Acts as boolean or if both inputs are booleans.

    note

    This is not short-circuited, meaning that if expressions are passed they are both evaluated.

    See also either, and, xor.

    example
    R.or(true, true); //=> true
    R.or(true, false); //=> true
    R.or(false, true); //=> true
    R.or(false, false); //=> false

    Type parameters

    • T

    • U

    Parameters

    Returns T | U

  • Type parameters

    • T

    Parameters

    Returns <U>(b: U) => T | U

      • <U>(b: U): T | U
      • Type parameters

        • U

        Parameters

        • b: U

        Returns T | U

  • otherwise<A, B>(onError: (error: any) => B | Promise<B>, promise: Promise<A>): Promise<B>
  • otherwise<A, B>(onError: (error: any) => B | Promise<B>): (promise: Promise<A>) => Promise<B>
  • Returns the result of applying the onFailure function to the value inside a failed Promise. This is useful for handling rejected Promises inside function compositions.

    example
    const failedFetch = (id: number) => Promise.reject('bad ID');
    const useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' });

    //recoverFromFailure :: String -> Promise ({ firstName, lastName })
    const recoverFromFailure = R.pipe(
    failedFetch,
    R.otherwise(useDefault),
    R.andThen(R.pick(['firstName', 'lastName'])),
    );
    recoverFromFailure(12345).then(console.log);

    Type parameters

    • A

    • B

    Parameters

    • onError: (error: any) => B | Promise<B>
        • (error: any): B | Promise<B>
        • Parameters

          • error: any

          Returns B | Promise<B>

    • promise: Promise<A>

    Returns Promise<B>

  • Type parameters

    • A

    • B

    Parameters

    • onError: (error: any) => B | Promise<B>
        • (error: any): B | Promise<B>
        • Parameters

          • error: any

          Returns B | Promise<B>

    Returns (promise: Promise<A>) => Promise<B>

      • (promise: Promise<A>): Promise<B>
      • Parameters

        • promise: Promise<A>

        Returns Promise<B>

  • over<S, A>(lens: Lens<S, A>, fn: (a: A) => A, value: S): S
  • over<S, A>(lens: Lens<S, A>, fn: (a: A) => A): (value: S) => S
  • over<S, A>(lens: Lens<S, A>): (fn: (a: A) => A, value: S) => S
  • Returns the result of "setting" the portion of the given data structure focused by the given lens to the given value.

    example
    const headLens = R.lensIndex<string>(0);

    R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz']

    Type parameters

    • S

    • A

    Parameters

    • lens: Lens<S, A>
    • fn: (a: A) => A
        • (a: A): A
        • Parameters

          • a: A

          Returns A

    • value: S

    Returns S

  • Type parameters

    • S

    • A

    Parameters

    • lens: Lens<S, A>
    • fn: (a: A) => A
        • (a: A): A
        • Parameters

          • a: A

          Returns A

    Returns (value: S) => S

      • (value: S): S
      • Parameters

        • value: S

        Returns S

  • Type parameters

    • S

    • A

    Parameters

    Returns (fn: (a: A) => A, value: S) => S

      • (fn: (a: A) => A, value: S): S
      • Parameters

        • fn: (a: A) => A
            • (a: A): A
            • Parameters

              • a: A

              Returns A

        • value: S

        Returns S

  • pair<F, S>(fst: F, snd: S): [F, S]
  • pair<F>(fst: F): <S>(snd: S) => [F, S]
  • Takes two arguments, fst and snd, and returns [fst, snd].

    See also objOf, of.

    example
    R.pair('foo', 'bar'); //=> ['foo', 'bar']
    

    Type parameters

    • F

    • S

    Parameters

    • fst: F
    • snd: S

    Returns [F, S]

  • Type parameters

    • F

    Parameters

    • fst: F

    Returns <S>(snd: S) => [F, S]

      • <S>(snd: S): [F, S]
      • Type parameters

        • S

        Parameters

        • snd: S

        Returns [F, S]

  • partial<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V0]): (x1: V1) => T
  • partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0, V1]): (x2: V2) => T
  • partial<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V0]): (x1: V1, x2: V2) => T
  • partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0, V1, V2]): (x2: V3) => T
  • partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0, V1]): (x2: V2, x3: V3) => T
  • partial<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V0]): (x1: V1, x2: V2, x3: V3) => T
  • partial<T>(fn: (...args: any[]) => T, args: unknown[]): (...args: unknown[]) => T
  • Takes a function f and a list of arguments, and returns a function g. When applied, g returns the result of applying f to the arguments provided initially followed by the arguments provided to g.

    See also partialRight, curry.

    example
    const multiply2 = (a: number, b: number) => a * b;
    const double = R.partial(multiply2, [2]);
    double(3); //=> 6

    const greet = (salutation: string, title: string, firstName: string, lastName: string) =>
    salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';

    const sayHello = R.partial(greet, ['Hello']);
    const sayHelloToMs = R.partial(sayHello, ['Ms.']);
    sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!'

    Type parameters

    • V0

    • V1

    • T

    Parameters

    • fn: (x0: V0, x1: V1) => T
        • (x0: V0, x1: V1): T
        • Parameters

          • x0: V0
          • x1: V1

          Returns T

    • args: [V0]

    Returns (x1: V1) => T

      • (x1: V1): T
      • Takes a function f and a list of arguments, and returns a function g. When applied, g returns the result of applying f to the arguments provided initially followed by the arguments provided to g.

        See also partialRight, curry.

        example
        const multiply2 = (a: number, b: number) => a * b;
        const double = R.partial(multiply2, [2]);
        double(3); //=> 6

        const greet = (salutation: string, title: string, firstName: string, lastName: string) =>
        salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';

        const sayHello = R.partial(greet, ['Hello']);
        const sayHelloToMs = R.partial(sayHello, ['Ms.']);
        sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!'

        Parameters

        • x1: V1

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2) => T
        • (x0: V0, x1: V1, x2: V2): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2

          Returns T

    • args: [V0, V1]

    Returns (x2: V2) => T

      • (x2: V2): T
      • Parameters

        • x2: V2

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2) => T
        • (x0: V0, x1: V1, x2: V2): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2

          Returns T

    • args: [V0]

    Returns (x1: V1, x2: V2) => T

      • (x1: V1, x2: V2): T
      • Parameters

        • x1: V1
        • x2: V2

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • V3

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T
        • (x0: V0, x1: V1, x2: V2, x3: V3): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2
          • x3: V3

          Returns T

    • args: [V0, V1, V2]

    Returns (x2: V3) => T

      • (x2: V3): T
      • Parameters

        • x2: V3

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • V3

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T
        • (x0: V0, x1: V1, x2: V2, x3: V3): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2
          • x3: V3

          Returns T

    • args: [V0, V1]

    Returns (x2: V2, x3: V3) => T

      • (x2: V2, x3: V3): T
      • Parameters

        • x2: V2
        • x3: V3

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • V3

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T
        • (x0: V0, x1: V1, x2: V2, x3: V3): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2
          • x3: V3

          Returns T

    • args: [V0]

    Returns (x1: V1, x2: V2, x3: V3) => T

      • (x1: V1, x2: V2, x3: V3): T
      • Parameters

        • x1: V1
        • x2: V2
        • x3: V3

        Returns T

  • Type parameters

    • T

    Parameters

    • fn: (...args: any[]) => T
        • (...args: any[]): T
        • Parameters

          • Rest ...args: any[]

          Returns T

    • args: unknown[]

    Returns (...args: unknown[]) => T

      • (...args: unknown[]): T
      • Parameters

        • Rest ...args: unknown[]

        Returns T

  • partialObject<T, P1, R>(fn: (value: T) => R, partial: P1): (value: Omit<T, keyof P1>) => R
  • partialObject<T, R>(fn: (value: T) => R): <P1>(partial: P1) => (value: Omit<T, keyof P1>) => R
  • Takes a function f and an object, and returns a function g. When applied, g returns the result of applying f to the object provided initially merged deeply (right) with the object provided as an argument to g.

    example
    const multiply2 = ({ a, b }: { a: number, b: number }) => a * b;
    const double = R.partialObject(multiply2, { a: 2 });
    double({ b: 2 }); //=> 4

    type GreetArgs = {
    salutation: string;
    title: string;
    firstName: string;
    lastName: string;
    };

    const greet = ({ salutation, title, firstName, lastName }: GreetArgs) =>
    salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';

    const sayHello = R.partialObject(greet, { salutation: 'Hello' });
    const sayHelloToMs = R.partialObject(sayHello, { title: 'Ms.' });
    sayHelloToMs({ firstName: 'Jane', lastName: 'Jones' }); //=> 'Hello, Ms. Jane Jones!'

    Type parameters

    • T

    • P1

    • R

    Parameters

    • fn: (value: T) => R
        • (value: T): R
        • Parameters

          • value: T

          Returns R

    • partial: P1

    Returns (value: Omit<T, keyof P1>) => R

      • (value: Omit<T, keyof P1>): R
      • Takes a function f and an object, and returns a function g. When applied, g returns the result of applying f to the object provided initially merged deeply (right) with the object provided as an argument to g.

        example
        const multiply2 = ({ a, b }: { a: number, b: number }) => a * b;
        const double = R.partialObject(multiply2, { a: 2 });
        double({ b: 2 }); //=> 4

        type GreetArgs = {
        salutation: string;
        title: string;
        firstName: string;
        lastName: string;
        };

        const greet = ({ salutation, title, firstName, lastName }: GreetArgs) =>
        salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';

        const sayHello = R.partialObject(greet, { salutation: 'Hello' });
        const sayHelloToMs = R.partialObject(sayHello, { title: 'Ms.' });
        sayHelloToMs({ firstName: 'Jane', lastName: 'Jones' }); //=> 'Hello, Ms. Jane Jones!'

        Parameters

        • value: Omit<T, keyof P1>

        Returns R

  • Type parameters

    • T

    • R

    Parameters

    • fn: (value: T) => R
        • (value: T): R
        • Parameters

          • value: T

          Returns R

    Returns <P1>(partial: P1) => (value: Omit<T, keyof P1>) => R

      • <P1>(partial: P1): (value: Omit<T, keyof P1>) => R
      • Type parameters

        • P1

        Parameters

        • partial: P1

        Returns (value: Omit<T, keyof P1>) => R

          • (value: Omit<T, keyof P1>): R
          • Parameters

            • value: Omit<T, keyof P1>

            Returns R

  • partialRight<V0, V1, T>(fn: (x0: V0, x1: V1) => T, args: [V1]): (x1: V0) => T
  • partialRight<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V1, V2]): (x2: V0) => T
  • partialRight<V0, V1, V2, T>(fn: (x0: V0, x1: V1, x2: V2) => T, args: [V2]): (x1: V0, x2: V1) => T
  • partialRight<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V1, V2, V3]): (x0: V0) => T
  • partialRight<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V2, V3]): (x0: V0, x1: V1) => T
  • partialRight<V0, V1, V2, V3, T>(fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T, args: [V3]): (x0: V0, x1: V1, x2: V2) => T
  • partialRight<T>(fn: (...args: any[]) => T, args: unknown[]): (...args: unknown[]) => T
  • Takes a function f and a list of arguments, and returns a function g. When applied, g returns the result of applying f to the arguments provided to g followed by the arguments provided initially.

    See also partial.

    example
    const greet = (salutation: string, title: string, firstName: string, lastName: string) =>
    salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';

    const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']);

    greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!'

    Type parameters

    • V0

    • V1

    • T

    Parameters

    • fn: (x0: V0, x1: V1) => T
        • (x0: V0, x1: V1): T
        • Parameters

          • x0: V0
          • x1: V1

          Returns T

    • args: [V1]

    Returns (x1: V0) => T

      • (x1: V0): T
      • Takes a function f and a list of arguments, and returns a function g. When applied, g returns the result of applying f to the arguments provided to g followed by the arguments provided initially.

        See also partial.

        example
        const greet = (salutation: string, title: string, firstName: string, lastName: string) =>
        salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';

        const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']);

        greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!'

        Parameters

        • x1: V0

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2) => T
        • (x0: V0, x1: V1, x2: V2): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2

          Returns T

    • args: [V1, V2]

    Returns (x2: V0) => T

      • (x2: V0): T
      • Parameters

        • x2: V0

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2) => T
        • (x0: V0, x1: V1, x2: V2): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2

          Returns T

    • args: [V2]

    Returns (x1: V0, x2: V1) => T

      • (x1: V0, x2: V1): T
      • Parameters

        • x1: V0
        • x2: V1

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • V3

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T
        • (x0: V0, x1: V1, x2: V2, x3: V3): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2
          • x3: V3

          Returns T

    • args: [V1, V2, V3]

    Returns (x0: V0) => T

      • (x0: V0): T
      • Parameters

        • x0: V0

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • V3

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T
        • (x0: V0, x1: V1, x2: V2, x3: V3): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2
          • x3: V3

          Returns T

    • args: [V2, V3]

    Returns (x0: V0, x1: V1) => T

      • (x0: V0, x1: V1): T
      • Parameters

        • x0: V0
        • x1: V1

        Returns T

  • Type parameters

    • V0

    • V1

    • V2

    • V3

    • T

    Parameters

    • fn: (x0: V0, x1: V1, x2: V2, x3: V3) => T
        • (x0: V0, x1: V1, x2: V2, x3: V3): T
        • Parameters

          • x0: V0
          • x1: V1
          • x2: V2
          • x3: V3

          Returns T

    • args: [V3]

    Returns (x0: V0, x1: V1, x2: V2) => T

      • (x0: V0, x1: V1, x2: V2): T
      • Parameters

        • x0: V0
        • x1: V1
        • x2: V2

        Returns T

  • Type parameters

    • T

    Parameters

    • fn: (...args: any[]) => T
        • (...args: any[]): T
        • Parameters

          • Rest ...args: any[]

          Returns T

    • args: unknown[]

    Returns (...args: unknown[]) => T

      • (...args: unknown[]): T
      • Parameters

        • Rest ...args: unknown[]

        Returns T

  • partition(fn: (a: string) => boolean, list: readonly string[]): [string[], string[]]
  • partition<T>(fn: (a: T) => boolean, list: readonly T[]): [T[], T[]]
  • partition<T>(fn: (a: T) => boolean): (list: readonly T[]) => [T[], T[]]
  • partition(fn: (a: string) => boolean): (list: readonly string[]) => [string[], string[]]
  • Takes a predicate and a list or other Filterable object and returns the elements split into two lists based on whether the element satisfied the predicate. Filterable objects include plain objects and objects with a filter method such as Array.

    See also filter, reject.

    example
    R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']);
    // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]

    R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' });
    // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ]

    Parameters

    • fn: (a: string) => boolean
        • (a: string): boolean
        • Parameters

          • a: string

          Returns boolean

    • list: readonly string[]

    Returns [string[], string[]]

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns [T[], T[]]

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns (list: readonly T[]) => [T[], T[]]

      • (list: readonly T[]): [T[], T[]]
      • Parameters

        • list: readonly T[]

        Returns [T[], T[]]

  • Parameters

    • fn: (a: string) => boolean
        • (a: string): boolean
        • Parameters

          • a: string

          Returns boolean

    Returns (list: readonly string[]) => [string[], string[]]

      • (list: readonly string[]): [string[], string[]]
      • Parameters

        • list: readonly string[]

        Returns [string[], string[]]

  • path<T>(path: Path, obj: any): T | undefined
  • path<T>(path: Path): (obj: any) => T | undefined
  • Retrieve the value at a given path.

    See also prop, nth.

    example
    R.path(['a', 'b'], {a: {b: 2}});             //=> 2
    R.path(['a', 'b'], {c: {b: 2}}); //=> undefined
    R.path(['a', 'b', 0], {a: {b: [1, 2, 3]}}); //=> 1
    R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2

    Type parameters

    • T

    Parameters

    Returns T | undefined

  • Type parameters

    • T

    Parameters

    Returns (obj: any) => T | undefined

      • (obj: any): T | undefined
      • Parameters

        • obj: any

        Returns T | undefined

  • pathEq(path: Path, val: any, obj: any): boolean
  • pathEq(path: Path, val: any): (obj: any) => boolean
  • pathEq(path: Path): _.F.Curry<(a: any, b: any) => boolean>
  • Determines whether a nested path on an object has a specific value, in R.equals terms. Most likely used to filter a list.

    example
    const user1 = { address: { zipCode: 90210 } };
    const user2 = { address: { zipCode: 55555 } };
    const user3 = { name: 'Bob' };
    const users = [ user1, user2, user3 ];
    const isFamous = R.pathEq(['address', 'zipCode'], 90210);
    R.filter(isFamous, users); //=> [ user1 ]

    Parameters

    • path: Path
    • val: any
    • obj: any

    Returns boolean

  • Parameters

    Returns (obj: any) => boolean

      • (obj: any): boolean
      • Parameters

        • obj: any

        Returns boolean

  • Parameters

    Returns _.F.Curry<(a: any, b: any) => boolean>

  • pathOr<T>(defaultValue: T, path: Path, obj: any): T
  • pathOr<T>(defaultValue: T, path: Path): (obj: any) => T
  • pathOr<T>(defaultValue: T): _.F.Curry<(a: Path, b: any) => T>
  • If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.

    example
    R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2
    R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A"

    Type parameters

    • T

    Parameters

    • defaultValue: T
    • path: Path
    • obj: any

    Returns T

  • Type parameters

    • T

    Parameters

    • defaultValue: T
    • path: Path

    Returns (obj: any) => T

      • (obj: any): T
      • Parameters

        • obj: any

        Returns T

  • Type parameters

    • T

    Parameters

    • defaultValue: T

    Returns _.F.Curry<(a: Path, b: any) => T>

  • pathSatisfies<T, U>(pred: (val: T) => boolean, path: Path, obj: U): boolean
  • pathSatisfies<T, U>(pred: (val: T) => boolean, path: Path): (obj: U) => boolean
  • pathSatisfies<T, U>(pred: (val: T) => boolean): _.F.Curry<(a: Path, b: U) => boolean>
  • Returns true if the specified object property at given path satisfies the given predicate; false otherwise.

    See also propSatisfies, path.

    example
    R.pathSatisfies((y: number) => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true
    R.pathSatisfies(R.is(Object), [], {x: {y: 2}}); //=> true

    Type parameters

    • T

    • U

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    • path: Path
    • obj: U

    Returns boolean

  • Type parameters

    • T

    • U

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    • path: Path

    Returns (obj: U) => boolean

      • (obj: U): boolean
      • Parameters

        • obj: U

        Returns boolean

  • Type parameters

    • T

    • U

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    Returns _.F.Curry<(a: Path, b: U) => boolean>

  • paths<T>(paths: readonly Path[], obj: any): (T | undefined)[]
  • paths<T>(paths: readonly Path[]): (obj: any) => (T | undefined)[]
  • Retrieves the values at given paths of an object.

    See also path.

    example
    R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3]
    R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined]

    Type parameters

    • T

    Parameters

    • paths: readonly Path[]
    • obj: any

    Returns (T | undefined)[]

  • Type parameters

    • T

    Parameters

    • paths: readonly Path[]

    Returns (obj: any) => (T | undefined)[]

      • (obj: any): (T | undefined)[]
      • Parameters

        • obj: any

        Returns (T | undefined)[]

  • pick<T, K>(names: readonly K[], obj: T): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>
  • pick<K>(names: readonly K[]): <T>(obj: T) => Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>
  • Returns a partial copy of an object containing only the keys specified. If the key does not exist, the property is ignored.

    See also omit, props.

    example
    R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
    R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1}

    Type parameters

    • T

    • K: string | number | symbol

    Parameters

    • names: readonly K[]
    • obj: T

    Returns Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>

  • Type parameters

    • K: string | number | symbol

    Parameters

    • names: readonly K[]

    Returns <T>(obj: T) => Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>

      • <T>(obj: T): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>
      • Type parameters

        • T

        Parameters

        • obj: T

        Returns Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>

  • pickAll<T, U>(names: readonly string[], obj: T): U
  • pickAll(names: readonly string[]): <T, U>(obj: T) => U
  • Similar to pick except that this one includes a key: undefined pair for properties that don't exist.

    example
    R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
    R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined}

    Type parameters

    • T

    • U

    Parameters

    • names: readonly string[]
    • obj: T

    Returns U

  • Parameters

    • names: readonly string[]

    Returns <T, U>(obj: T) => U

      • <T, U>(obj: T): U
      • Type parameters

        • T

        • U

        Parameters

        • obj: T

        Returns U

  • pickBy<T, U>(pred: ObjPred<T>, obj: T): U
  • pickBy<T>(pred: ObjPred<T>): <U, V>(obj: V) => U
  • Returns a partial copy of an object containing only the keys that satisfy the supplied predicate.

    example
    const isUpperCase = <T>(_val: T, key: string) => key.toUpperCase() === key;
    R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}

    Type parameters

    • T

    • U

    Parameters

    Returns U

  • Type parameters

    • T

    Parameters

    Returns <U, V>(obj: V) => U

      • <U, V>(obj: V): U
      • Type parameters

        • U

        • V: T

        Parameters

        • obj: V

        Returns U

  • pipe<TArgs, R1, R2, R3, R4, R5, R6, R7, TResult>(...funcs: [f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7, ...func: ((a: any) => any)[], fnLast: (a: any) => TResult]): (...args: TArgs) => TResult
  • pipe<TArgs, R1, R2, R3, R4, R5, R6, R7>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7): (...args: TArgs) => R7
  • pipe<TArgs, R1, R2, R3, R4, R5, R6>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6): (...args: TArgs) => R6
  • pipe<TArgs, R1, R2, R3, R4, R5>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5): (...args: TArgs) => R5
  • pipe<TArgs, R1, R2, R3, R4>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4): (...args: TArgs) => R4
  • pipe<TArgs, R1, R2, R3>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3): (...args: TArgs) => R3
  • pipe<TArgs, R1, R2>(f1: (...args: TArgs) => R1, f2: (a: R1) => R2): (...args: TArgs) => R2
  • pipe<TArgs, R1>(f1: (...args: TArgs) => R1): (...args: TArgs) => R1
  • Creates a new function that runs each of the functions supplied as parameters in turn, passing the return value of each function invocation to the next function invocation, beginning with whatever arguments were passed to the initial invocation.

    Performs left-to-right function composition. The first argument may have any arity; the remaining arguments must be unary.

    In some libraries this function is named sequence.

    note

    The result of pipe is not automatically curried.

    See also compose.

    example
    const f = R.pipe(Math.pow, R.negate, R.inc);

    f(3, 4); // -(3^4) + 1

    Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    • R6

    • R7

    • TResult

    Parameters

    • Rest ...funcs: [f1: (...args: TArgs) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3, f4: (a: R3) => R4, f5: (a: R4) => R5, f6: (a: R5) => R6, f7: (a: R6) => R7, ...func: ((a: any) => any)[], fnLast: (a: any) => TResult]

    Returns (...args: TArgs) => TResult

      • (...args: TArgs): TResult
      • Creates a new function that runs each of the functions supplied as parameters in turn, passing the return value of each function invocation to the next function invocation, beginning with whatever arguments were passed to the initial invocation.

        Performs left-to-right function composition. The first argument may have any arity; the remaining arguments must be unary.

        In some libraries this function is named sequence.

        note

        The result of pipe is not automatically curried.

        See also compose.

        example
        const f = R.pipe(Math.pow, R.negate, R.inc);

        f(3, 4); // -(3^4) + 1

        Parameters

        • Rest ...args: TArgs

        Returns TResult

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    • R6

    • R7

    Parameters

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f4: (a: R3) => R4
        • (a: R3): R4
        • Parameters

          • a: R3

          Returns R4

    • f5: (a: R4) => R5
        • (a: R4): R5
        • Parameters

          • a: R4

          Returns R5

    • f6: (a: R5) => R6
        • (a: R5): R6
        • Parameters

          • a: R5

          Returns R6

    • f7: (a: R6) => R7
        • (a: R6): R7
        • Parameters

          • a: R6

          Returns R7

    Returns (...args: TArgs) => R7

      • (...args: TArgs): R7
      • Parameters

        • Rest ...args: TArgs

        Returns R7

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    • R6

    Parameters

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f4: (a: R3) => R4
        • (a: R3): R4
        • Parameters

          • a: R3

          Returns R4

    • f5: (a: R4) => R5
        • (a: R4): R5
        • Parameters

          • a: R4

          Returns R5

    • f6: (a: R5) => R6
        • (a: R5): R6
        • Parameters

          • a: R5

          Returns R6

    Returns (...args: TArgs) => R6

      • (...args: TArgs): R6
      • Parameters

        • Rest ...args: TArgs

        Returns R6

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    • R5

    Parameters

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f4: (a: R3) => R4
        • (a: R3): R4
        • Parameters

          • a: R3

          Returns R4

    • f5: (a: R4) => R5
        • (a: R4): R5
        • Parameters

          • a: R4

          Returns R5

    Returns (...args: TArgs) => R5

      • (...args: TArgs): R5
      • Parameters

        • Rest ...args: TArgs

        Returns R5

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    • R4

    Parameters

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    • f4: (a: R3) => R4
        • (a: R3): R4
        • Parameters

          • a: R3

          Returns R4

    Returns (...args: TArgs) => R4

      • (...args: TArgs): R4
      • Parameters

        • Rest ...args: TArgs

        Returns R4

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    • R3

    Parameters

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    • f3: (a: R2) => R3
        • (a: R2): R3
        • Parameters

          • a: R2

          Returns R3

    Returns (...args: TArgs) => R3

      • (...args: TArgs): R3
      • Parameters

        • Rest ...args: TArgs

        Returns R3

  • Type parameters

    • TArgs: any[]

    • R1

    • R2

    Parameters

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    • f2: (a: R1) => R2
        • (a: R1): R2
        • Parameters

          • a: R1

          Returns R2

    Returns (...args: TArgs) => R2

      • (...args: TArgs): R2
      • Parameters

        • Rest ...args: TArgs

        Returns R2

  • Type parameters

    • TArgs: any[]

    • R1

    Parameters

    • f1: (...args: TArgs) => R1
        • (...args: TArgs): R1
        • Parameters

          • Rest ...args: TArgs

          Returns R1

    Returns (...args: TArgs) => R1

      • (...args: TArgs): R1
      • Parameters

        • Rest ...args: TArgs

        Returns R1

  • pipeK<V0, T1>(fn0: (x0: V0) => T1[]): (x0: V0) => T1[]
  • pipeK<V0, T1, T2>(fn0: (x0: V0) => T1[], fn1: (x: T1) => T2[]): (x0: V0) => T2[]
  • pipeK<V0, T1, T2, T3>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[]): (x: V0) => T3[]
  • pipeK<V0, T1, T2, T3, T4>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[]): (x: V0) => T4[]
  • pipeK<V0, T1, T2, T3, T4, T5>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[]): (x: V0) => T5[]
  • pipeK<V0, T1, T2, T3, T4, T5, T6>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[]): (x: V0) => T6[]
  • pipeK<V0, T1, T2, T3, T4, T5, T6, T7>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[], fn: (x: T6) => T7[]): (x: V0) => T7[]
  • pipeK<V0, T1, T2, T3, T4, T5, T6, T7, T8>(fn0: (x: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[], fn6: (x: T6) => T7[], fn: (x: T7) => T8[]): (x: V0) => T8[]
  • pipeK<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(fn0: (x0: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[], fn6: (x: T6) => T7[], fn7: (x: T7) => T8[], fn8: (x: T8) => T9[]): (x0: V0) => T9[]
  • pipeK<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(fn0: (x0: V0) => T1[], fn1: (x: T1) => T2[], fn2: (x: T2) => T3[], fn3: (x: T3) => T4[], fn4: (x: T4) => T5[], fn5: (x: T5) => T6[], fn6: (x: T6) => T7[], fn7: (x: T7) => T8[], fn8: (x: T8) => T9[], fn9: (x: T9) => T10[]): (x0: V0) => T10[]
  • Returns the left-to-right Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. The typings currently support arrays only as return values. All functions need to be unary. R.pipeK(f, g, h) is equivalent to R.pipe(f, R.chain(g), R.chain(h)).

    deprecated

    since 0.26 in favor of pipeWith(chain)

    Type parameters

    • V0

    • T1

    Parameters

    • fn0: (x0: V0) => T1[]
        • (x0: V0): T1[]
        • Parameters

          • x0: V0

          Returns T1[]

    Returns (x0: V0) => T1[]

      • (x0: V0): T1[]
      • Returns the left-to-right Kleisli composition of the provided functions, each of which must return a value of a type supported by chain. The typings currently support arrays only as return values. All functions need to be unary. R.pipeK(f, g, h) is equivalent to R.pipe(f, R.chain(g), R.chain(h)).

        deprecated

        since 0.26 in favor of pipeWith(chain)

        Parameters

        • x0: V0

        Returns T1[]

  • Type parameters

    • V0

    • T1

    • T2

    Parameters

    • fn0: (x0: V0) => T1[]
        • (x0: V0): T1[]
        • Parameters

          • x0: V0

          Returns T1[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    Returns (x0: V0) => T2[]

      • (x0: V0): T2[]
      • Parameters

        • x0: V0

        Returns T2[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    Parameters

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    Returns (x: V0) => T3[]

      • (x: V0): T3[]
      • Parameters

        • x: V0

        Returns T3[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    Parameters

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    Returns (x: V0) => T4[]

      • (x: V0): T4[]
      • Parameters

        • x: V0

        Returns T4[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    • fn4: (x: T4) => T5[]
        • (x: T4): T5[]
        • Parameters

          • x: T4

          Returns T5[]

    Returns (x: V0) => T5[]

      • (x: V0): T5[]
      • Parameters

        • x: V0

        Returns T5[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    • fn4: (x: T4) => T5[]
        • (x: T4): T5[]
        • Parameters

          • x: T4

          Returns T5[]

    • fn5: (x: T5) => T6[]
        • (x: T5): T6[]
        • Parameters

          • x: T5

          Returns T6[]

    Returns (x: V0) => T6[]

      • (x: V0): T6[]
      • Parameters

        • x: V0

        Returns T6[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    Parameters

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    • fn4: (x: T4) => T5[]
        • (x: T4): T5[]
        • Parameters

          • x: T4

          Returns T5[]

    • fn5: (x: T5) => T6[]
        • (x: T5): T6[]
        • Parameters

          • x: T5

          Returns T6[]

    • fn: (x: T6) => T7[]
        • (x: T6): T7[]
        • Parameters

          • x: T6

          Returns T7[]

    Returns (x: V0) => T7[]

      • (x: V0): T7[]
      • Parameters

        • x: V0

        Returns T7[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    Parameters

    • fn0: (x: V0) => T1[]
        • (x: V0): T1[]
        • Parameters

          • x: V0

          Returns T1[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    • fn4: (x: T4) => T5[]
        • (x: T4): T5[]
        • Parameters

          • x: T4

          Returns T5[]

    • fn5: (x: T5) => T6[]
        • (x: T5): T6[]
        • Parameters

          • x: T5

          Returns T6[]

    • fn6: (x: T6) => T7[]
        • (x: T6): T7[]
        • Parameters

          • x: T6

          Returns T7[]

    • fn: (x: T7) => T8[]
        • (x: T7): T8[]
        • Parameters

          • x: T7

          Returns T8[]

    Returns (x: V0) => T8[]

      • (x: V0): T8[]
      • Parameters

        • x: V0

        Returns T8[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    Parameters

    • fn0: (x0: V0) => T1[]
        • (x0: V0): T1[]
        • Parameters

          • x0: V0

          Returns T1[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    • fn4: (x: T4) => T5[]
        • (x: T4): T5[]
        • Parameters

          • x: T4

          Returns T5[]

    • fn5: (x: T5) => T6[]
        • (x: T5): T6[]
        • Parameters

          • x: T5

          Returns T6[]

    • fn6: (x: T6) => T7[]
        • (x: T6): T7[]
        • Parameters

          • x: T6

          Returns T7[]

    • fn7: (x: T7) => T8[]
        • (x: T7): T8[]
        • Parameters

          • x: T7

          Returns T8[]

    • fn8: (x: T8) => T9[]
        • (x: T8): T9[]
        • Parameters

          • x: T8

          Returns T9[]

    Returns (x0: V0) => T9[]

      • (x0: V0): T9[]
      • Parameters

        • x0: V0

        Returns T9[]

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    • T10

    Parameters

    • fn0: (x0: V0) => T1[]
        • (x0: V0): T1[]
        • Parameters

          • x0: V0

          Returns T1[]

    • fn1: (x: T1) => T2[]
        • (x: T1): T2[]
        • Parameters

          • x: T1

          Returns T2[]

    • fn2: (x: T2) => T3[]
        • (x: T2): T3[]
        • Parameters

          • x: T2

          Returns T3[]

    • fn3: (x: T3) => T4[]
        • (x: T3): T4[]
        • Parameters

          • x: T3

          Returns T4[]

    • fn4: (x: T4) => T5[]
        • (x: T4): T5[]
        • Parameters

          • x: T4

          Returns T5[]

    • fn5: (x: T5) => T6[]
        • (x: T5): T6[]
        • Parameters

          • x: T5

          Returns T6[]

    • fn6: (x: T6) => T7[]
        • (x: T6): T7[]
        • Parameters

          • x: T6

          Returns T7[]

    • fn7: (x: T7) => T8[]
        • (x: T7): T8[]
        • Parameters

          • x: T7

          Returns T8[]

    • fn8: (x: T8) => T9[]
        • (x: T8): T9[]
        • Parameters

          • x: T8

          Returns T9[]

    • fn9: (x: T9) => T10[]
        • (x: T9): T10[]
        • Parameters

          • x: T9

          Returns T10[]

    Returns (x0: V0) => T10[]

      • (x0: V0): T10[]
      • Parameters

        • x0: V0

        Returns T10[]

  • pipeP<V0, T1>(fn0: (x0: V0) => Promise<T1>): (x0: V0) => Promise<T1>
  • pipeP<V0, T1, T2>(fn0: (x0: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>): (x0: V0) => Promise<T2>
  • pipeP<V0, T1, T2, T3>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>): (x: V0) => Promise<T3>
  • pipeP<V0, T1, T2, T3, T4>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>): (x: V0) => Promise<T4>
  • pipeP<V0, T1, T2, T3, T4, T5>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>): (x: V0) => Promise<T5>
  • pipeP<V0, T1, T2, T3, T4, T5, T6>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>): (x: V0) => Promise<T6>
  • pipeP<V0, T1, T2, T3, T4, T5, T6, T7>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>, fn: (x: T6) => Promise<T7>): (x: V0) => Promise<T7>
  • pipeP<V0, T1, T2, T3, T4, T5, T6, T7, T8>(fn0: (x: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>, fn6: (x: T6) => Promise<T7>, fn: (x: T7) => Promise<T8>): (x: V0) => Promise<T8>
  • pipeP<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(fn0: (x0: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>, fn6: (x: T6) => Promise<T7>, fn7: (x: T7) => Promise<T8>, fn8: (x: T8) => Promise<T9>): (x0: V0) => Promise<T9>
  • pipeP<V0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(fn0: (x0: V0) => Promise<T1>, fn1: (x: T1) => Promise<T2>, fn2: (x: T2) => Promise<T3>, fn3: (x: T3) => Promise<T4>, fn4: (x: T4) => Promise<T5>, fn5: (x: T5) => Promise<T6>, fn6: (x: T6) => Promise<T7>, fn7: (x: T7) => Promise<T8>, fn8: (x: T8) => Promise<T9>, fn9: (x: T9) => Promise<T10>): (x0: V0) => Promise<T10>
  • Performs left-to-right composition of one or more Promise-returning functions. All functions need to be unary.

    deprecated

    since 0.26 in favor of pipeWith(then)

    Type parameters

    • V0

    • T1

    Parameters

    • fn0: (x0: V0) => Promise<T1>
        • (x0: V0): Promise<T1>
        • Parameters

          • x0: V0

          Returns Promise<T1>

    Returns (x0: V0) => Promise<T1>

      • (x0: V0): Promise<T1>
      • Performs left-to-right composition of one or more Promise-returning functions. All functions need to be unary.

        deprecated

        since 0.26 in favor of pipeWith(then)

        Parameters

        • x0: V0

        Returns Promise<T1>

  • Type parameters

    • V0

    • T1

    • T2

    Parameters

    • fn0: (x0: V0) => Promise<T1>
        • (x0: V0): Promise<T1>
        • Parameters

          • x0: V0

          Returns Promise<T1>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    Returns (x0: V0) => Promise<T2>

      • (x0: V0): Promise<T2>
      • Parameters

        • x0: V0

        Returns Promise<T2>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    Parameters

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    Returns (x: V0) => Promise<T3>

      • (x: V0): Promise<T3>
      • Parameters

        • x: V0

        Returns Promise<T3>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    Parameters

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    Returns (x: V0) => Promise<T4>

      • (x: V0): Promise<T4>
      • Parameters

        • x: V0

        Returns Promise<T4>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    • fn4: (x: T4) => Promise<T5>
        • (x: T4): Promise<T5>
        • Parameters

          • x: T4

          Returns Promise<T5>

    Returns (x: V0) => Promise<T5>

      • (x: V0): Promise<T5>
      • Parameters

        • x: V0

        Returns Promise<T5>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    • fn4: (x: T4) => Promise<T5>
        • (x: T4): Promise<T5>
        • Parameters

          • x: T4

          Returns Promise<T5>

    • fn5: (x: T5) => Promise<T6>
        • (x: T5): Promise<T6>
        • Parameters

          • x: T5

          Returns Promise<T6>

    Returns (x: V0) => Promise<T6>

      • (x: V0): Promise<T6>
      • Parameters

        • x: V0

        Returns Promise<T6>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    Parameters

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    • fn4: (x: T4) => Promise<T5>
        • (x: T4): Promise<T5>
        • Parameters

          • x: T4

          Returns Promise<T5>

    • fn5: (x: T5) => Promise<T6>
        • (x: T5): Promise<T6>
        • Parameters

          • x: T5

          Returns Promise<T6>

    • fn: (x: T6) => Promise<T7>
        • (x: T6): Promise<T7>
        • Parameters

          • x: T6

          Returns Promise<T7>

    Returns (x: V0) => Promise<T7>

      • (x: V0): Promise<T7>
      • Parameters

        • x: V0

        Returns Promise<T7>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    Parameters

    • fn0: (x: V0) => Promise<T1>
        • (x: V0): Promise<T1>
        • Parameters

          • x: V0

          Returns Promise<T1>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    • fn4: (x: T4) => Promise<T5>
        • (x: T4): Promise<T5>
        • Parameters

          • x: T4

          Returns Promise<T5>

    • fn5: (x: T5) => Promise<T6>
        • (x: T5): Promise<T6>
        • Parameters

          • x: T5

          Returns Promise<T6>

    • fn6: (x: T6) => Promise<T7>
        • (x: T6): Promise<T7>
        • Parameters

          • x: T6

          Returns Promise<T7>

    • fn: (x: T7) => Promise<T8>
        • (x: T7): Promise<T8>
        • Parameters

          • x: T7

          Returns Promise<T8>

    Returns (x: V0) => Promise<T8>

      • (x: V0): Promise<T8>
      • Parameters

        • x: V0

        Returns Promise<T8>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    Parameters

    • fn0: (x0: V0) => Promise<T1>
        • (x0: V0): Promise<T1>
        • Parameters

          • x0: V0

          Returns Promise<T1>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    • fn4: (x: T4) => Promise<T5>
        • (x: T4): Promise<T5>
        • Parameters

          • x: T4

          Returns Promise<T5>

    • fn5: (x: T5) => Promise<T6>
        • (x: T5): Promise<T6>
        • Parameters

          • x: T5

          Returns Promise<T6>

    • fn6: (x: T6) => Promise<T7>
        • (x: T6): Promise<T7>
        • Parameters

          • x: T6

          Returns Promise<T7>

    • fn7: (x: T7) => Promise<T8>
        • (x: T7): Promise<T8>
        • Parameters

          • x: T7

          Returns Promise<T8>

    • fn8: (x: T8) => Promise<T9>
        • (x: T8): Promise<T9>
        • Parameters

          • x: T8

          Returns Promise<T9>

    Returns (x0: V0) => Promise<T9>

      • (x0: V0): Promise<T9>
      • Parameters

        • x0: V0

        Returns Promise<T9>

  • Type parameters

    • V0

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    • T10

    Parameters

    • fn0: (x0: V0) => Promise<T1>
        • (x0: V0): Promise<T1>
        • Parameters

          • x0: V0

          Returns Promise<T1>

    • fn1: (x: T1) => Promise<T2>
        • (x: T1): Promise<T2>
        • Parameters

          • x: T1

          Returns Promise<T2>

    • fn2: (x: T2) => Promise<T3>
        • (x: T2): Promise<T3>
        • Parameters

          • x: T2

          Returns Promise<T3>

    • fn3: (x: T3) => Promise<T4>
        • (x: T3): Promise<T4>
        • Parameters

          • x: T3

          Returns Promise<T4>

    • fn4: (x: T4) => Promise<T5>
        • (x: T4): Promise<T5>
        • Parameters

          • x: T4

          Returns Promise<T5>

    • fn5: (x: T5) => Promise<T6>
        • (x: T5): Promise<T6>
        • Parameters

          • x: T5

          Returns Promise<T6>

    • fn6: (x: T6) => Promise<T7>
        • (x: T6): Promise<T7>
        • Parameters

          • x: T6

          Returns Promise<T7>

    • fn7: (x: T7) => Promise<T8>
        • (x: T7): Promise<T8>
        • Parameters

          • x: T7

          Returns Promise<T8>

    • fn8: (x: T8) => Promise<T9>
        • (x: T8): Promise<T9>
        • Parameters

          • x: T8

          Returns Promise<T9>

    • fn9: (x: T9) => Promise<T10>
        • (x: T9): Promise<T10>
        • Parameters

          • x: T9

          Returns Promise<T10>

    Returns (x0: V0) => Promise<T10>

      • (x0: V0): Promise<T10>
      • Parameters

        • x0: V0

        Returns Promise<T10>

  • Performs left-to-right function composition using transforming function. The first function may have any arity; the remaining functions must be unary.

    note

    The result of pipeWith is not automatically curried. Transforming function is not used on the first argument.

    See also composeWith, pipe.

    example
    const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res));
    const f = pipeWhileNotNil([Math.pow, R.negate, R.inc])

    f(3, 4); // -(3^4) + 1

    Type parameters

    • TArgs: any[]

    • TResult

    Parameters

    Returns (...args: TArgs) => TResult

      • (...args: TArgs): TResult
      • Performs left-to-right function composition using transforming function. The first function may have any arity; the remaining functions must be unary.

        note

        The result of pipeWith is not automatically curried. Transforming function is not used on the first argument.

        See also composeWith, pipe.

        example
        const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res));
        const f = pipeWhileNotNil([Math.pow, R.negate, R.inc])

        f(3, 4); // -(3^4) + 1

        Parameters

        • Rest ...args: TArgs

        Returns TResult

  • Parameters

    • transformer: (fn: AnyFunction, intermediateResult: any) => any

    Returns <TArgs, TResult>(fns: AtLeastOneFunctionsFlow<TArgs, TResult>) => (...args: TArgs) => TResult

      • Type parameters

        • TArgs: any[]

        • TResult

        Parameters

        Returns (...args: TArgs) => TResult

          • (...args: TArgs): TResult
          • Parameters

            • Rest ...args: TArgs

            Returns TResult

  • pluck<K, T>(p: K, list: readonly T[]): T[K][]
  • pluck<T>(p: number, list: readonly {}[]): T[]
  • pluck<P>(p: P): <T>(list: ReadonlyArray<Record<P, T>>) => T[]
  • pluck(p: number): <T>(list: ReadonlyArray<{}>) => T[]
  • Returns a new list by plucking the same named property off all objects in the list supplied.

    pluck will work on any functor in addition to arrays, as it is equivalent to R.map(R.prop(k), f).

    See also project, prop, props.

    example
    var getAges = R.pluck('age');
    const people = [{name: 'fred', age: 29}, {name: 'wilma', age: 27}]
    getAges(people); //=> [29, 27]

    R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3]
    R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5}

    Type parameters

    • K: string | number | symbol

    • T

    Parameters

    • p: K
    • list: readonly T[]

    Returns T[K][]

  • Type parameters

    • T

    Parameters

    • p: number
    • list: readonly {}[]

    Returns T[]

  • Type parameters

    • P: string

    Parameters

    • p: P

    Returns <T>(list: ReadonlyArray<Record<P, T>>) => T[]

      • <T>(list: ReadonlyArray<Record<P, T>>): T[]
      • Type parameters

        • T

        Parameters

        • list: ReadonlyArray<Record<P, T>>

        Returns T[]

  • Parameters

    • p: number

    Returns <T>(list: ReadonlyArray<{}>) => T[]

      • <T>(list: ReadonlyArray<{}>): T[]
      • Type parameters

        • T

        Parameters

        • list: ReadonlyArray<{}>

        Returns T[]

  • prepend<T>(el: T, list: readonly T[]): T[]
  • prepend<T>(el: T): (list: readonly T[]) => T[]
  • Returns a new list with the given element at the front, followed by the contents of the list.

    See also append.

    example
    R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum']
    

    Type parameters

    • T

    Parameters

    • el: T
    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • el: T

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • product(list: readonly number[]): number
  • Multiplies together all the elements of a list.

    See also reduce.

    example
    R.product([2,4,6,8,100,1]); //=> 38400
    

    Parameters

    • list: readonly number[]

    Returns number

  • project<T, U>(props: readonly string[], objs: readonly T[]): U[]
  • project<T, U>(props: readonly string[]): (objs: readonly T[]) => U[]
  • Reasonable analog to SQL select statement.

    See also pluck, props, prop.

    example
    const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2};
    const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7};
    const kids = [abby, fred];
    R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]

    Type parameters

    • T

    • U

    Parameters

    • props: readonly string[]
    • objs: readonly T[]

    Returns U[]

  • Type parameters

    • T

    • U

    Parameters

    • props: readonly string[]

    Returns (objs: readonly T[]) => U[]

      • (objs: readonly T[]): U[]
      • Parameters

        • objs: readonly T[]

        Returns U[]

  • promap<A, B, C, D>(pre: (value: A) => B, post: (value: C) => D, fn: (value: B) => C): (value: A) => D
  • promap<A, B, C, D>(pre: (value: A) => B, post: (value: C) => D): (fn: (value: B) => C) => (value: A) => D
  • promap<A, B>(pre: (value: A) => B): <C, D>(post: (value: C) => D, fn: (value: B) => C) => (value: A) => D
  • Takes two functions as pre- and post- processors respectively for a third function, i.e. promap(f, g, h)(x) === g(h(f(x))). Dispatches to the promap method of the third argument, if present, according to the FantasyLand Profunctor spec. Acts as a transducer if a transformer is given in profunctor position.

    See also transduce.

    example
    const decodeChar = R.promap((s: string) => s.charCodeAt(0), String.fromCharCode, R.add(-8))
    const decodeString = R.promap(R.split(''), R.join(''), R.map(decodeChar))
    decodeString("ziuli") //=> "ramda"

    Type parameters

    • A

    • B

    • C

    • D

    Parameters

    • pre: (value: A) => B
        • (value: A): B
        • Parameters

          • value: A

          Returns B

    • post: (value: C) => D
        • (value: C): D
        • Parameters

          • value: C

          Returns D

    • fn: (value: B) => C
        • (value: B): C
        • Parameters

          • value: B

          Returns C

    Returns (value: A) => D

      • (value: A): D
      • Takes two functions as pre- and post- processors respectively for a third function, i.e. promap(f, g, h)(x) === g(h(f(x))). Dispatches to the promap method of the third argument, if present, according to the FantasyLand Profunctor spec. Acts as a transducer if a transformer is given in profunctor position.

        See also transduce.

        example
        const decodeChar = R.promap((s: string) => s.charCodeAt(0), String.fromCharCode, R.add(-8))
        const decodeString = R.promap(R.split(''), R.join(''), R.map(decodeChar))
        decodeString("ziuli") //=> "ramda"

        Parameters

        • value: A

        Returns D

  • Type parameters

    • A

    • B

    • C

    • D

    Parameters

    • pre: (value: A) => B
        • (value: A): B
        • Parameters

          • value: A

          Returns B

    • post: (value: C) => D
        • (value: C): D
        • Parameters

          • value: C

          Returns D

    Returns (fn: (value: B) => C) => (value: A) => D

      • (fn: (value: B) => C): (value: A) => D
      • Parameters

        • fn: (value: B) => C
            • (value: B): C
            • Parameters

              • value: B

              Returns C

        Returns (value: A) => D

          • (value: A): D
          • Parameters

            • value: A

            Returns D

  • Type parameters

    • A

    • B

    Parameters

    • pre: (value: A) => B
        • (value: A): B
        • Parameters

          • value: A

          Returns B

    Returns <C, D>(post: (value: C) => D, fn: (value: B) => C) => (value: A) => D

      • <C, D>(post: (value: C) => D, fn: (value: B) => C): (value: A) => D
      • Type parameters

        • C

        • D

        Parameters

        • post: (value: C) => D
            • (value: C): D
            • Parameters

              • value: C

              Returns D

        • fn: (value: B) => C
            • (value: B): C
            • Parameters

              • value: B

              Returns C

        Returns (value: A) => D

          • (value: A): D
          • Parameters

            • value: A

            Returns D

  • prop<T>(__: Placeholder, obj: T): <P>(p: P) => T[P]
  • prop<P, T>(p: P, obj: T): T[P]
  • prop<P>(p: P): <T>(obj: Record<P, T>) => T
  • prop<P, T>(p: P): (obj: Record<P, T>) => T
  • Returns a function that when supplied an object returns the indicated property of that object, if it exists.

    See also propOr, path, props, pluck, project, nth.

    example
    R.prop('x', {x: 100}); //=> 100
    R.prop(0, [100]); //=> 100
    R.compose(R.inc, R.prop<'x', number>('x'))({ x: 3 }) //=> 4

    Type parameters

    • T

    Parameters

    Returns <P>(p: P) => T[P]

      • <P>(p: P): T[P]
      • Returns a function that when supplied an object returns the indicated property of that object, if it exists.

        See also propOr, path, props, pluck, project, nth.

        example
        R.prop('x', {x: 100}); //=> 100
        R.prop(0, [100]); //=> 100
        R.compose(R.inc, R.prop<'x', number>('x'))({ x: 3 }) //=> 4

        Type parameters

        • P: keyof T

        Parameters

        • p: P

        Returns T[P]

  • Type parameters

    • P: string | number | symbol

    • T

    Parameters

    • p: P
    • obj: T

    Returns T[P]

  • Type parameters

    • P: string

    Parameters

    • p: P

    Returns <T>(obj: Record<P, T>) => T

      • <T>(obj: Record<P, T>): T
      • Type parameters

        • T

        Parameters

        • obj: Record<P, T>

        Returns T

  • Type parameters

    • P: string

    • T

    Parameters

    • p: P

    Returns (obj: Record<P, T>) => T

      • (obj: Record<P, T>): T
      • Parameters

        • obj: Record<P, T>

        Returns T

  • propEq<K>(name: K, val: any, obj: Record<K, any>): boolean
  • propEq<K>(name: K, val: any): (obj: Record<K, any>) => boolean
  • propEq<K>(name: K): { (val: any, obj: Record<K, any>): boolean; (val: any): (obj: Record<K, any>) => boolean }
  • Returns true if the specified object property is equal, in R.equals terms, to the given value; false otherwise. You can test multiple properties with R.whereEq.

    example
    const abby = {name: 'Abby', age: 7, hair: 'blond'};
    const fred = {name: 'Fred', age: 12, hair: 'brown'};
    const rusty = {name: 'Rusty', age: 10, hair: 'brown'};
    const alois = {name: 'Alois', age: 15, hair: 'brown', disposition: 'surly'};
    const kids = [abby, fred, rusty, alois];
    const hasBrownHair = R.propEq('hair', 'brown');
    R.filter(hasBrownHair, kids); //=> [fred, rusty]

    Type parameters

    • K: string | number

    Parameters

    • name: K
    • val: any
    • obj: Record<K, any>

    Returns boolean

  • Type parameters

    • K: string | number

    Parameters

    • name: K
    • val: any

    Returns (obj: Record<K, any>) => boolean

      • (obj: Record<K, any>): boolean
      • Parameters

        • obj: Record<K, any>

        Returns boolean

  • Type parameters

    • K: string | number

    Parameters

    • name: K

    Returns { (val: any, obj: Record<K, any>): boolean; (val: any): (obj: Record<K, any>) => boolean }

      • (val: any, obj: Record<K, any>): boolean
      • (val: any): (obj: Record<K, any>) => boolean
      • Parameters

        • val: any
        • obj: Record<K, any>

        Returns boolean

      • Parameters

        • val: any

        Returns (obj: Record<K, any>) => boolean

          • (obj: Record<K, any>): boolean
          • Parameters

            • obj: Record<K, any>

            Returns boolean

  • propIs<C, K>(type: C, name: K, obj: any): obj is Record<K, ReturnType<C>>
  • propIs<C, K>(type: C, name: K, obj: any): obj is Record<K, InstanceType<C>>
  • propIs<C, K>(type: C, name: K): (obj: any) => obj is Record<K, ReturnType<C>>
  • propIs<C, K>(type: C, name: K): (obj: any) => obj is Record<K, InstanceType<C>>
  • propIs<C>(type: C): { <K>(name: K, obj: any): obj is Record<K, ReturnType<C>>; <K>(name: K): (obj: any) => obj is Record<K, ReturnType<C>> }
  • propIs<C>(type: C): { <K>(name: K, obj: any): obj is Record<K, InstanceType<C>>; <K>(name: K): (obj: any) => obj is Record<K, InstanceType<C>> }
  • Returns true if the specified object property is of the given type; false otherwise.

    See also is, propSatisfies.

    example
    R.propIs(Number, 'x', {x: 1, y: 2});  //=> true
    R.propIs(Number, 'x', {x: 'foo'}); //=> false
    R.propIs(Number, 'x', {}); //=> false

    Type parameters

    Parameters

    • type: C
    • name: K
    • obj: any

    Returns obj is Record<K, ReturnType<C>>

  • Type parameters

    Parameters

    • type: C
    • name: K
    • obj: any

    Returns obj is Record<K, InstanceType<C>>

  • Type parameters

    Parameters

    • type: C
    • name: K

    Returns (obj: any) => obj is Record<K, ReturnType<C>>

      • (obj: any): obj is Record<K, ReturnType<C>>
      • Parameters

        • obj: any

        Returns obj is Record<K, ReturnType<C>>

  • Type parameters

    Parameters

    • type: C
    • name: K

    Returns (obj: any) => obj is Record<K, InstanceType<C>>

      • (obj: any): obj is Record<K, InstanceType<C>>
      • Parameters

        • obj: any

        Returns obj is Record<K, InstanceType<C>>

  • Type parameters

    Parameters

    • type: C

    Returns { <K>(name: K, obj: any): obj is Record<K, ReturnType<C>>; <K>(name: K): (obj: any) => obj is Record<K, ReturnType<C>> }

      • <K>(name: K, obj: any): obj is Record<K, ReturnType<C>>
      • <K>(name: K): (obj: any) => obj is Record<K, ReturnType<C>>
      • Type parameters

        • K: string | number | symbol

        Parameters

        • name: K
        • obj: any

        Returns obj is Record<K, ReturnType<C>>

      • Type parameters

        • K: string | number | symbol

        Parameters

        • name: K

        Returns (obj: any) => obj is Record<K, ReturnType<C>>

          • (obj: any): obj is Record<K, ReturnType<C>>
          • Parameters

            • obj: any

            Returns obj is Record<K, ReturnType<C>>

  • Type parameters

    Parameters

    • type: C

    Returns { <K>(name: K, obj: any): obj is Record<K, InstanceType<C>>; <K>(name: K): (obj: any) => obj is Record<K, InstanceType<C>> }

      • <K>(name: K, obj: any): obj is Record<K, InstanceType<C>>
      • <K>(name: K): (obj: any) => obj is Record<K, InstanceType<C>>
      • Type parameters

        • K: string | number | symbol

        Parameters

        • name: K
        • obj: any

        Returns obj is Record<K, InstanceType<C>>

      • Type parameters

        • K: string | number | symbol

        Parameters

        • name: K

        Returns (obj: any) => obj is Record<K, InstanceType<C>>

          • (obj: any): obj is Record<K, InstanceType<C>>
          • Parameters

            • obj: any

            Returns obj is Record<K, InstanceType<C>>

  • propOr<T, U>(val: T, __: Placeholder, obj: U): <V>(p: string) => V
  • propOr<U>(__: Placeholder, p: string, obj: U): <T, V>(val: T) => V
  • propOr<T, U, V>(val: T, p: string, obj: U): V
  • propOr<T>(val: T, p: string): <U, V>(obj: U) => V
  • propOr<T>(val: T): <U, V>(p: string, obj: U) => V
  • Return the specified property of the given non-null object if the property is present and its value is not null, undefined or NaN.

    Otherwise the first argument is returned.

    See also prop.

    example
    const alice = {
    name: 'ALICE',
    age: 101
    };
    const favorite = R.prop('favoriteLibrary');
    const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');

    favorite(alice as any); //=> undefined
    favoriteWithDefault(alice); //=> 'Ramda'

    Type parameters

    • T

    • U

    Parameters

    Returns <V>(p: string) => V

      • <V>(p: string): V
      • Return the specified property of the given non-null object if the property is present and its value is not null, undefined or NaN.

        Otherwise the first argument is returned.

        See also prop.

        example
        const alice = {
        name: 'ALICE',
        age: 101
        };
        const favorite = R.prop('favoriteLibrary');
        const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');

        favorite(alice as any); //=> undefined
        favoriteWithDefault(alice); //=> 'Ramda'

        Type parameters

        • V

        Parameters

        • p: string

        Returns V

  • Type parameters

    • U

    Parameters

    Returns <T, V>(val: T) => V

      • <T, V>(val: T): V
      • Type parameters

        • T

        • V

        Parameters

        • val: T

        Returns V

  • Type parameters

    • T

    • U

    • V

    Parameters

    • val: T
    • p: string
    • obj: U

    Returns V

  • Type parameters

    • T

    Parameters

    • val: T
    • p: string

    Returns <U, V>(obj: U) => V

      • <U, V>(obj: U): V
      • Type parameters

        • U

        • V

        Parameters

        • obj: U

        Returns V

  • Type parameters

    • T

    Parameters

    • val: T

    Returns <U, V>(p: string, obj: U) => V

      • <U, V>(p: string, obj: U): V
      • Type parameters

        • U

        • V

        Parameters

        • p: string
        • obj: U

        Returns V

  • propSatisfies<P, K>(pred: (val: any) => val is P, name: K, obj: any): obj is Record<K, P>
  • propSatisfies<P, K>(pred: (val: any) => val is P, name: K): (obj: any) => obj is Record<K, P>
  • propSatisfies<P>(pred: (val: any) => val is P): { <K>(name: K, obj: any): obj is Record<K, P>; <K>(name: K): (obj: any) => obj is Record<K, P> }
  • propSatisfies(pred: (val: any) => boolean, name: string | number | symbol, obj: any): boolean
  • propSatisfies(pred: (val: any) => boolean, name: string | number | symbol): (obj: any) => boolean
  • propSatisfies(pred: (val: any) => boolean): _.F.Curry<(a: keyof any, b: any) => boolean>
  • Returns true if the specified object property satisfies the given predicate; false otherwise. You can test multiple properties with R.where.

    See also where, propEq, propIs.

    example
    const val = {x: 1, y: 2};
    R.propSatisfies(x => x > 0, 'x', val); //=> true

    Type parameters

    • P

    • K: string | number | symbol

    Parameters

    • pred: (val: any) => val is P
        • (val: any): val is P
        • Parameters

          • val: any

          Returns val is P

    • name: K
    • obj: any

    Returns obj is Record<K, P>

  • Type parameters

    • P

    • K: string | number | symbol

    Parameters

    • pred: (val: any) => val is P
        • (val: any): val is P
        • Parameters

          • val: any

          Returns val is P

    • name: K

    Returns (obj: any) => obj is Record<K, P>

      • (obj: any): obj is Record<K, P>
      • Parameters

        • obj: any

        Returns obj is Record<K, P>

  • Type parameters

    • P

    Parameters

    • pred: (val: any) => val is P
        • (val: any): val is P
        • Parameters

          • val: any

          Returns val is P

    Returns { <K>(name: K, obj: any): obj is Record<K, P>; <K>(name: K): (obj: any) => obj is Record<K, P> }

      • <K>(name: K, obj: any): obj is Record<K, P>
      • <K>(name: K): (obj: any) => obj is Record<K, P>
      • Type parameters

        • K: string | number | symbol

        Parameters

        • name: K
        • obj: any

        Returns obj is Record<K, P>

      • Type parameters

        • K: string | number | symbol

        Parameters

        • name: K

        Returns (obj: any) => obj is Record<K, P>

          • (obj: any): obj is Record<K, P>
          • Parameters

            • obj: any

            Returns obj is Record<K, P>

  • Parameters

    • pred: (val: any) => boolean
        • (val: any): boolean
        • Parameters

          • val: any

          Returns boolean

    • name: string | number | symbol
    • obj: any

    Returns boolean

  • Parameters

    • pred: (val: any) => boolean
        • (val: any): boolean
        • Parameters

          • val: any

          Returns boolean

    • name: string | number | symbol

    Returns (obj: any) => boolean

      • (obj: any): boolean
      • Parameters

        • obj: any

        Returns boolean

  • Parameters

    • pred: (val: any) => boolean
        • (val: any): boolean
        • Parameters

          • val: any

          Returns boolean

    Returns _.F.Curry<(a: keyof any, b: any) => boolean>

  • props<P, T>(ps: readonly P[], obj: Record<P, T>): T[]
  • props<P>(ps: readonly P[]): <T>(obj: Record<P, T>) => T[]
  • props<P, T>(ps: readonly P[]): (obj: Record<P, T>) => T[]
  • Acts as multiple prop: array of keys in, array of values out. Preserves order.

    See also prop, pluck, project.

    example
    R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2]
    R.props(['c', 'a', 'b'], {b: 2, a: 1, c: 3}); //=> [3, 1, 2]

    const fullName = R.compose(R.join(' '), R.props(['first', 'last']));
    const tony = {last: 'Bullet-Tooth', age: 33, first: 'Tony'};
    fullName(tony); //=> 'Tony Bullet-Tooth'

    Type parameters

    • P: string

    • T

    Parameters

    • ps: readonly P[]
    • obj: Record<P, T>

    Returns T[]

  • Type parameters

    • P: string

    Parameters

    • ps: readonly P[]

    Returns <T>(obj: Record<P, T>) => T[]

      • <T>(obj: Record<P, T>): T[]
      • Type parameters

        • T

        Parameters

        • obj: Record<P, T>

        Returns T[]

  • Type parameters

    • P: string

    • T

    Parameters

    • ps: readonly P[]

    Returns (obj: Record<P, T>) => T[]

      • (obj: Record<P, T>): T[]
      • Parameters

        • obj: Record<P, T>

        Returns T[]

  • range(from: number, to: number): number[]
  • range(from: number): (to: number) => number[]
  • Returns a list of numbers from from (inclusive) to to (exclusive). In mathematical terms, range(a, b) is equivalent to the half-open interval [a, b).

    example
    R.range(1, 5);    //=> [1, 2, 3, 4]
    R.range(50, 53); //=> [50, 51, 52]

    Parameters

    • from: number
    • to: number

    Returns number[]

  • Parameters

    • from: number

    Returns (to: number) => number[]

      • (to: number): number[]
      • Parameters

        • to: number

        Returns number[]

  • reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>, acc: TResult, list: readonly T[]): TResult
  • reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>): (acc: TResult, list: readonly T[]) => TResult
  • reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>, acc: TResult): (list: readonly T[]) => TResult
  • Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.

    The iterator function receives two values: (acc, value). It may use R.reduced to shortcut the iteration.

    note

    R.reduce does not skip deleted or unassigned indices (sparse arrays), unlike the native Array.prototype.reduce method.

    Dispatches to the reduce method of the third argument, if present. When doing so, it is up to the user to handle the R.reduced shortcutting, as this is not implemented by reduce.

    See also reduced, addIndex, reduceRight.

    example
    R.reduce(R.subtract, 0, [1, 2, 3, 4]) //=> ((((0 - 1) - 2) - 3) - 4) = -10
    // - -10
    // / \ / \
    // - 4 -6 4
    // / \ / \
    // - 3 ==> -3 3
    // / \ / \
    // - 2 -1 2
    // / \ / \
    // 0 1 0 1

    Type parameters

    • T

    • TResult

    Parameters

    • fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>
        • (acc: TResult, elem: T): TResult | Reduced<TResult>
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult | Reduced<TResult>

    • acc: TResult
    • list: readonly T[]

    Returns TResult

  • Type parameters

    • T

    • TResult

    Parameters

    • fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>
        • (acc: TResult, elem: T): TResult | Reduced<TResult>
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult | Reduced<TResult>

    Returns (acc: TResult, list: readonly T[]) => TResult

      • (acc: TResult, list: readonly T[]): TResult
      • Parameters

        • acc: TResult
        • list: readonly T[]

        Returns TResult

  • Type parameters

    • T

    • TResult

    Parameters

    • fn: (acc: TResult, elem: T) => TResult | Reduced<TResult>
        • (acc: TResult, elem: T): TResult | Reduced<TResult>
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult | Reduced<TResult>

    • acc: TResult

    Returns (list: readonly T[]) => TResult

      • (list: readonly T[]): TResult
      • Parameters

        • list: readonly T[]

        Returns TResult

  • reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string, list: readonly T[]): {}
  • reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string): (list: readonly T[]) => {}
  • reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult): _.F.Curry<(a: (elem: T) => string, b: readonly T[]) => {}>
  • reduceBy<T, TResult>(valueFn: (acc: TResult, elem: T) => TResult): _.F.Curry<(a: TResult, b: (elem: T) => string, c: readonly T[]) => {}>
  • Groups the elements of the list according to the result of calling the string-returning function keyFn on each element and reduces the elements of each group to a single value via the reducer function valueFn.

    The value function receives two values: (acc, value). It may use R.reduced to short circuit the iteration.

    This function is basically a more general R.groupBy function.

    Acts as a transducer if a transformer is given in list position.

    See also groupBy, reduce, reduced, transduce.

    example
    const groupNames = (acc: string[], { name }: { name: string; }) => acc.concat(name)
    const toGrade = ({ score }: { score: number; }) =>
    score < 65 ? 'F' :
    score < 70 ? 'D' :
    score < 80 ? 'C' :
    score < 90 ? 'B' : 'A'

    var students = [
    {name: 'Abby', score: 83},
    {name: 'Bart', score: 62},
    {name: 'Curt', score: 88},
    {name: 'Dora', score: 92},
    ]

    R.reduceBy(groupNames, [], toGrade, students)
    //=> {"A": ["Dora"], "B": ["Abby", "Curt"], "F": ["Bart"]}

    Type parameters

    • T

    • TResult

    Parameters

    • valueFn: (acc: TResult, elem: T) => TResult
        • (acc: TResult, elem: T): TResult
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult

    • acc: TResult
    • keyFn: (elem: T) => string
        • (elem: T): string
        • Parameters

          • elem: T

          Returns string

    • list: readonly T[]

    Returns {}

    • [index: string]: TResult
  • Type parameters

    • T

    • TResult

    Parameters

    • valueFn: (acc: TResult, elem: T) => TResult
        • (acc: TResult, elem: T): TResult
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult

    • acc: TResult
    • keyFn: (elem: T) => string
        • (elem: T): string
        • Parameters

          • elem: T

          Returns string

    Returns (list: readonly T[]) => {}

      • (list: readonly T[]): {}
      • Parameters

        • list: readonly T[]

        Returns {}

        • [index: string]: TResult
  • Type parameters

    • T

    • TResult

    Parameters

    • valueFn: (acc: TResult, elem: T) => TResult
        • (acc: TResult, elem: T): TResult
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult

    • acc: TResult

    Returns _.F.Curry<(a: (elem: T) => string, b: readonly T[]) => {}>

  • Type parameters

    • T

    • TResult

    Parameters

    • valueFn: (acc: TResult, elem: T) => TResult
        • (acc: TResult, elem: T): TResult
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult

    Returns _.F.Curry<(a: TResult, b: (elem: T) => string, c: readonly T[]) => {}>

  • reduceRight<T, TResult>(fn: (elem: T, acc: TResult) => TResult, acc: TResult, list: readonly T[]): TResult
  • reduceRight<T, TResult>(fn: (elem: T, acc: TResult) => TResult): (acc: TResult, list: readonly T[]) => TResult
  • reduceRight<T, TResult>(fn: (elem: T, acc: TResult) => TResult, acc: TResult): (list: readonly T[]) => TResult
  • Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.

    Similar to R.reduce, except moves through the input list from the right to the left.

    The iterator function receives two values: (value, acc), reversed compared to that of R.reduce's iterator function. reduceRight may use R.reduced to short circuit the iteration.

    note

    R.reduceRight does not skip deleted or unassigned indices (sparse arrays), unlike the native Array.prototype.reduceRight method.

    See also reduce, addIndex, reduced.

    example
    R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2
    // - -2
    // / \ / \
    // 1 - 1 3
    // / \ / \
    // 2 - ==> 2 -1
    // / \ / \
    // 3 - 3 4
    // / \ / \
    // 4 0 4 0

    Type parameters

    • T

    • TResult

    Parameters

    • fn: (elem: T, acc: TResult) => TResult
        • (elem: T, acc: TResult): TResult
        • Parameters

          • elem: T
          • acc: TResult

          Returns TResult

    • acc: TResult
    • list: readonly T[]

    Returns TResult

  • Type parameters

    • T

    • TResult

    Parameters

    • fn: (elem: T, acc: TResult) => TResult
        • (elem: T, acc: TResult): TResult
        • Parameters

          • elem: T
          • acc: TResult

          Returns TResult

    Returns (acc: TResult, list: readonly T[]) => TResult

      • (acc: TResult, list: readonly T[]): TResult
      • Parameters

        • acc: TResult
        • list: readonly T[]

        Returns TResult

  • Type parameters

    • T

    • TResult

    Parameters

    • fn: (elem: T, acc: TResult) => TResult
        • (elem: T, acc: TResult): TResult
        • Parameters

          • elem: T
          • acc: TResult

          Returns TResult

    • acc: TResult

    Returns (list: readonly T[]) => TResult

      • (list: readonly T[]): TResult
      • Parameters

        • list: readonly T[]

        Returns TResult

  • reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult, acc: TResult, list: readonly T[]): TResult
  • reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult, acc: TResult): (list: readonly T[]) => TResult
  • reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean, fn: (acc: TResult, elem: T) => TResult): _.F.Curry<(a: TResult, b: readonly T[]) => TResult>
  • reduceWhile<T, TResult>(predicate: (acc: TResult, elem: T) => boolean): _.F.Curry<(a: (acc: TResult, elem: T) => TResult, b: TResult, c: readonly T[]) => TResult>
  • Like R.reduce, R.reduceWhile returns a single item by iterating through the list, successively calling the iterator function. R.reduceWhile also takes a predicate that is evaluated before each step. If the predicate returns a falsy value, it "short-circuits" the iteration and returns the current value of the accumulator.

    See also reduce, reduced.

    example
    const isOdd = (acc: number, x: number) => x % 2 !== 0;
    const xs = [1, 3, 5, 60, 777, 800];
    R.reduceWhile(isOdd, R.add, 0, xs); //=> 9

    const ys = [2, 4, 6]
    R.reduceWhile(isOdd, R.add, 111, ys); //=> 111

    Type parameters

    • T

    • TResult

    Parameters

    • predicate: (acc: TResult, elem: T) => boolean
        • (acc: TResult, elem: T): boolean
        • Parameters

          • acc: TResult
          • elem: T

          Returns boolean

    • fn: (acc: TResult, elem: T) => TResult
        • (acc: TResult, elem: T): TResult
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult

    • acc: TResult
    • list: readonly T[]

    Returns TResult

  • Type parameters

    • T

    • TResult

    Parameters

    • predicate: (acc: TResult, elem: T) => boolean
        • (acc: TResult, elem: T): boolean
        • Parameters

          • acc: TResult
          • elem: T

          Returns boolean

    • fn: (acc: TResult, elem: T) => TResult
        • (acc: TResult, elem: T): TResult
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult

    • acc: TResult

    Returns (list: readonly T[]) => TResult

      • (list: readonly T[]): TResult
      • Parameters

        • list: readonly T[]

        Returns TResult

  • Type parameters

    • T

    • TResult

    Parameters

    • predicate: (acc: TResult, elem: T) => boolean
        • (acc: TResult, elem: T): boolean
        • Parameters

          • acc: TResult
          • elem: T

          Returns boolean

    • fn: (acc: TResult, elem: T) => TResult
        • (acc: TResult, elem: T): TResult
        • Parameters

          • acc: TResult
          • elem: T

          Returns TResult

    Returns _.F.Curry<(a: TResult, b: readonly T[]) => TResult>

  • Type parameters

    • T

    • TResult

    Parameters

    • predicate: (acc: TResult, elem: T) => boolean
        • (acc: TResult, elem: T): boolean
        • Parameters

          • acc: TResult
          • elem: T

          Returns boolean

    Returns _.F.Curry<(a: (acc: TResult, elem: T) => TResult, b: TResult, c: readonly T[]) => TResult>

  • Returns a value wrapped to indicate that it is the final value of the R.reduce and R.transduce functions. The returned value should be considered a black box: the internal structure is not guaranteed to be stable.

    This optimization is available to the below functions:

    • R.reduce
    • R.reduceWhile
    • R.reduceBy
    • R.reduceRight
    • R.transduce

    See also reduce, reduceWhile, reduceBy, reduceRight, transduce.

    example
    R.reduce(
    (acc, item) => item > 3 ? R.reduced(acc) : acc.concat(item),
    [] as number[],
    [1, 2, 3, 4, 5]) // [1, 2, 3]

    Type parameters

    • T

    Parameters

    • elem: T

    Returns Reduced<T>

  • reject<A, P>(pred: (val: A) => val is P): { <B>(list: readonly B[]): Exclude<B, P>[]; <B>(dict: Dictionary<B>): Dictionary<Exclude<B, P>> }
  • reject<T>(pred: (value: T) => boolean): <P, C>(collection: C) => C
  • reject<A, B, P>(pred: (val: A) => val is P, list: readonly B[]): Exclude<B, P>[]
  • reject<A, B, P>(pred: (val: A) => val is P, dict: Dictionary<B>): Dictionary<Exclude<B, P>>
  • reject<T, C>(pred: (value: T) => boolean, collection: C): C
  • The complement of R.filter.

    Acts as a transducer if a transformer is given in list position. Filterable objects include plain objects or any object that has a filter method such as Array.

    See also filter, transduce, addIndex.

    example
    const isOdd = (n: number) => n % 2 !== 0;

    R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4]

    R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}

    Type parameters

    • A

    • P

    Parameters

    • pred: (val: A) => val is P
        • (val: A): val is P
        • Parameters

          • val: A

          Returns val is P

    Returns { <B>(list: readonly B[]): Exclude<B, P>[]; <B>(dict: Dictionary<B>): Dictionary<Exclude<B, P>> }

      • Type parameters

        • B

        Parameters

        • list: readonly B[]

        Returns Exclude<B, P>[]

      • Type parameters

        • B

        Parameters

        Returns Dictionary<Exclude<B, P>>

  • Type parameters

    • T

    Parameters

    • pred: (value: T) => boolean
        • (value: T): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns <P, C>(collection: C) => C

      • <P, C>(collection: C): C
      • Type parameters

        Parameters

        • collection: C

        Returns C

  • Type parameters

    • A

    • B

    • P

    Parameters

    • pred: (val: A) => val is P
        • (val: A): val is P
        • Parameters

          • val: A

          Returns val is P

    • list: readonly B[]

    Returns Exclude<B, P>[]

  • Type parameters

    • A

    • B

    • P

    Parameters

    • pred: (val: A) => val is P
        • (val: A): val is P
        • Parameters

          • val: A

          Returns val is P

    • dict: Dictionary<B>

    Returns Dictionary<Exclude<B, P>>

  • Type parameters

    Parameters

    • pred: (value: T) => boolean
        • (value: T): boolean
        • Parameters

          • value: T

          Returns boolean

    • collection: C

    Returns C

  • remove<T>(start: number, count: number, list: readonly T[]): T[]
  • remove<T>(start: number): { (count: number, list: readonly T[]): T[]; (count: number): (list: readonly T[]) => T[] }
  • remove<T>(start: number, count: number): (list: readonly T[]) => T[]
  • Returns a copy of the given list with the given number of elements removed, starting at the given start index.

    See also without.

    example
    R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8]
    

    Type parameters

    • T

    Parameters

    • start: number
    • count: number
    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • start: number

    Returns { (count: number, list: readonly T[]): T[]; (count: number): (list: readonly T[]) => T[] }

      • (count: number, list: readonly T[]): T[]
      • (count: number): (list: readonly T[]) => T[]
      • Parameters

        • count: number
        • list: readonly T[]

        Returns T[]

      • Parameters

        • count: number

        Returns (list: readonly T[]) => T[]

          • (list: readonly T[]): T[]
          • Parameters

            • list: readonly T[]

            Returns T[]

  • Type parameters

    • T

    Parameters

    • start: number
    • count: number

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • repeat<T>(a: T, n: number): T[]
  • repeat<T>(a: T): (n: number) => T[]
  • Returns a fixed list of size n, containing a specified identical value.

    See also times.

    example
    R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi']

    const obj = {};
    const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}]
    repeatedObjs[0] === repeatedObjs[1]; //=> true

    Type parameters

    • T

    Parameters

    • a: T
    • n: number

    Returns T[]

  • Type parameters

    • T

    Parameters

    • a: T

    Returns (n: number) => T[]

      • (n: number): T[]
      • Parameters

        • n: number

        Returns T[]

  • replace(pattern: string | RegExp, replacement: string | ((match: string, ...args: readonly any[]) => string), str: string): string
  • replace(pattern: string | RegExp, replacement: string | ((match: string, ...args: readonly any[]) => string)): (str: string) => string
  • replace(pattern: string | RegExp): (replacement: string | ((match: string, ...args: readonly any[]) => string)) => (str: string) => string
  • Replace a substring or regex match in a string with a replacement.

    The first two parameters correspond to the parameters of String.prototype.replace, so the second parameter can also be a function.

    example
    R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
    R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'

    // Use the "g" (global) flag to replace all occurrences:
    R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'

    Parameters

    • pattern: string | RegExp
    • replacement: string | ((match: string, ...args: readonly any[]) => string)
    • str: string

    Returns string

  • Parameters

    • pattern: string | RegExp
    • replacement: string | ((match: string, ...args: readonly any[]) => string)

    Returns (str: string) => string

      • (str: string): string
      • Parameters

        • str: string

        Returns string

  • Parameters

    • pattern: string | RegExp

    Returns (replacement: string | ((match: string, ...args: readonly any[]) => string)) => (str: string) => string

      • (replacement: string | ((match: string, ...args: readonly any[]) => string)): (str: string) => string
      • Parameters

        • replacement: string | ((match: string, ...args: readonly any[]) => string)

        Returns (str: string) => string

          • (str: string): string
          • Parameters

            • str: string

            Returns string

  • reverse<T>(list: readonly T[]): T[]
  • reverse(str: string): string
  • Returns a new list or string with the elements in reverse order.

    example
    R.reverse([1, 2, 3]);  //=> [3, 2, 1]
    R.reverse([1, 2]); //=> [2, 1]
    R.reverse([1]); //=> [1]
    R.reverse([]); //=> []

    R.reverse('abc'); //=> 'cba'
    R.reverse('ab'); //=> 'ba'
    R.reverse('a'); //=> 'a'
    R.reverse(''); //=> ''

    Type parameters

    • T

    Parameters

    • list: readonly T[]

    Returns T[]

  • Parameters

    • str: string

    Returns string

  • scan<T, TResult>(fn: (acc: TResult, elem: T) => any, acc: TResult, list: readonly T[]): TResult[]
  • scan<T, TResult>(fn: (acc: TResult, elem: T) => any, acc: TResult): (list: readonly T[]) => TResult[]
  • scan<T, TResult>(fn: (acc: TResult, elem: T) => any): (acc: TResult, list: readonly T[]) => TResult[]
  • Similar to R.reduce, but returns a list of successively reduced values from the left.

    See also reduce, mapAccum.

    example
    const numbers = [1, 2, 3, 4];
    const factorials = R.scan(R.multiply, 1 as number, numbers); //=> [1, 1, 2, 6, 24]

    Type parameters

    • T

    • TResult

    Parameters

    • fn: (acc: TResult, elem: T) => any
        • (acc: TResult, elem: T): any
        • Parameters

          • acc: TResult
          • elem: T

          Returns any

    • acc: TResult
    • list: readonly T[]

    Returns TResult[]

  • Type parameters

    • T

    • TResult

    Parameters

    • fn: (acc: TResult, elem: T) => any
        • (acc: TResult, elem: T): any
        • Parameters

          • acc: TResult
          • elem: T

          Returns any

    • acc: TResult

    Returns (list: readonly T[]) => TResult[]

      • (list: readonly T[]): TResult[]
      • Parameters

        • list: readonly T[]

        Returns TResult[]

  • Type parameters

    • T

    • TResult

    Parameters

    • fn: (acc: TResult, elem: T) => any
        • (acc: TResult, elem: T): any
        • Parameters

          • acc: TResult
          • elem: T

          Returns any

    Returns (acc: TResult, list: readonly T[]) => TResult[]

      • (acc: TResult, list: readonly T[]): TResult[]
      • Parameters

        • acc: TResult
        • list: readonly T[]

        Returns TResult[]

  • set<S, A>(lens: Lens<S, A>, a: A, obj: S): S
  • set<S, A>(lens: Lens<S, A>, a: A): (obj: S) => S
  • set<S, A>(lens: Lens<S, A>): (a: A, obj: S) => S
  • Returns the result of "setting" the portion of the given data structure focused by the given lens to the given value.

    example
    const xLens = R.lensProp<'x', number>('x');

    const point = {x: 1, y: 2};
    R.set(xLens, 4, point); //=> {x: 4, y: 2}
    R.set(xLens, 8, point); //=> {x: 8, y: 2}

    Type parameters

    • S

    • A

    Parameters

    • lens: Lens<S, A>
    • a: A
    • obj: S

    Returns S

  • Type parameters

    • S

    • A

    Parameters

    • lens: Lens<S, A>
    • a: A

    Returns (obj: S) => S

      • (obj: S): S
      • Parameters

        • obj: S

        Returns S

  • Type parameters

    • S

    • A

    Parameters

    Returns (a: A, obj: S) => S

      • (a: A, obj: S): S
      • Parameters

        • a: A
        • obj: S

        Returns S

  • slice(a: number, b: number, list: string): string
  • slice<T>(a: number, b: number, list: readonly T[]): T[]
  • slice(a: number, b: number): { <T>(list: readonly T[]): T[]; (list: string): string }
  • slice(a: number): { <T>(b: number, list: readonly T[]): T[]; (b: number, list: string): string }
  • Returns the elements of the given list or string from fromIndex (inclusive) to toIndex (exclusive).

    Dispatches to the slice method of the third argument, if present.

    example
    R.slice(1, 3, ['a', 'b', 'c', 'd']);        //=> ['b', 'c']
    R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd']
    R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c']
    R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
    R.slice(0, 3, 'ramda'); //=> 'ram'

    Parameters

    • a: number
    • b: number
    • list: string

    Returns string

  • Type parameters

    • T

    Parameters

    • a: number
    • b: number
    • list: readonly T[]

    Returns T[]

  • Parameters

    • a: number
    • b: number

    Returns { <T>(list: readonly T[]): T[]; (list: string): string }

      • <T>(list: readonly T[]): T[]
      • (list: string): string
      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns T[]

      • Parameters

        • list: string

        Returns string

  • Parameters

    • a: number

    Returns { <T>(b: number, list: readonly T[]): T[]; (b: number, list: string): string }

      • <T>(b: number, list: readonly T[]): T[]
      • (b: number, list: string): string
      • Type parameters

        • T

        Parameters

        • b: number
        • list: readonly T[]

        Returns T[]

      • Parameters

        • b: number
        • list: string

        Returns string

  • sort<T>(fn: (a: T, b: T) => number, list: readonly T[]): T[]
  • sort<T>(fn: (a: T, b: T) => number): (list: readonly T[]) => T[]
  • Returns a copy of the list, sorted according to the comparator function, which should accept two values at a time and return:

    • a negative number if the first value is smaller,
    • a positive number if it's larger, and
    • zero if they are equal.
    example
    R.sort(R.subtract, [4,2,7,5]); //=> [2, 4, 5, 7]
    

    Type parameters

    • T

    Parameters

    • fn: (a: T, b: T) => number
        • (a: T, b: T): number
        • Parameters

          • a: T
          • b: T

          Returns number

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • fn: (a: T, b: T) => number
        • (a: T, b: T): number
        • Parameters

          • a: T
          • b: T

          Returns number

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • sortBy<T>(fn: (a: T) => Ord, list: readonly T[]): T[]
  • sortBy<T>(fn: (a: T) => Ord): (list: readonly T[]) => T[]
  • sortBy(fn: (a: any) => Ord): <T>(list: readonly T[]) => T[]
  • Sorts the list according to a key generated by the supplied function.

    See also sort, sortWith, ascend, descend.

    example
    type Person = { name: string; age: number; };

    const sortByFirstItem = R.sortBy(R.prop(0));
    const pairs = [[-1, 1], [-2, 2], [-3, 3]];
    sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]
    const sortByNameCaseInsensitive = R.sortBy<Person>(R.compose(R.toLower, R.prop('name')));
    const alice = {
    name: 'ALICE',
    age: 101
    };
    const bob = {
    name: 'Bob',
    age: -10
    };
    const clara = {
    name: 'clara',
    age: 314.159
    };
    const people = [clara, bob, alice];
    sortByNameCaseInsensitive(people); //=> [alice, bob, clara]

    Type parameters

    • T

    Parameters

    • fn: (a: T) => Ord
        • Parameters

          • a: T

          Returns Ord

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => Ord
        • Parameters

          • a: T

          Returns Ord

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • Parameters

    • fn: (a: any) => Ord
        • Parameters

          • a: any

          Returns Ord

    Returns <T>(list: readonly T[]) => T[]

      • <T>(list: readonly T[]): T[]
      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns T[]

  • sortWith<T>(fns: readonly ((a: T, b: T) => number)[], list: readonly T[]): T[]
  • sortWith<T>(fns: readonly ((a: T, b: T) => number)[]): (list: readonly T[]) => T[]
  • Sorts a list according to a list of comparators.

    See also sort, sortBy, ascend, descend.

    example
    type Person = { age: number; name: string; };

    const alice = {
    name: 'alice',
    age: 40
    };
    const bob = {
    name: 'bob',
    age: 30
    };
    const clara = {
    name: 'clara',
    age: 40
    };
    const people = [clara, bob, alice];
    const ageNameSort = R.sortWith<Person>([
    R.descend(R.prop('age')),
    R.ascend(R.prop('name'))
    ]);
    ageNameSort(people); //=> [alice, clara, bob]

    Type parameters

    • T

    Parameters

    • fns: readonly ((a: T, b: T) => number)[]
    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • fns: readonly ((a: T, b: T) => number)[]

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • split(sep: string | RegExp): (str: string) => string[]
  • split(sep: string | RegExp, str: string): string[]
  • Splits a string into an array of strings based on the given separator.

    See also join.

    example
    const pathComponents = R.split('/');
    R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node']

    R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd']

    Parameters

    • sep: string | RegExp

    Returns (str: string) => string[]

      • (str: string): string[]
      • Splits a string into an array of strings based on the given separator.

        See also join.

        example
        const pathComponents = R.split('/');
        R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node']

        R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd']

        Parameters

        • str: string

        Returns string[]

  • Parameters

    • sep: string | RegExp
    • str: string

    Returns string[]

  • splitAt<T>(index: number, list: readonly T[]): [T[], T[]]
  • splitAt(index: number, list: string): [string, string]
  • splitAt(index: number): { <T>(list: readonly T[]): [T[], T[]]; (list: string): [string, string] }
  • Splits a given list or string at a given index.

    example
    R.splitAt(1, [1, 2, 3]);          //=> [[1], [2, 3]]
    R.splitAt(5, 'hello world'); //=> ['hello', ' world']
    R.splitAt(-1, 'foobar'); //=> ['fooba', 'r']

    Type parameters

    • T

    Parameters

    • index: number
    • list: readonly T[]

    Returns [T[], T[]]

  • Parameters

    • index: number
    • list: string

    Returns [string, string]

  • Parameters

    • index: number

    Returns { <T>(list: readonly T[]): [T[], T[]]; (list: string): [string, string] }

      • <T>(list: readonly T[]): [T[], T[]]
      • (list: string): [string, string]
      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns [T[], T[]]

      • Parameters

        • list: string

        Returns [string, string]

  • splitEvery<T>(a: number, list: readonly T[]): T[][]
  • splitEvery(a: number, list: string): string[]
  • splitEvery(a: number): { (list: string): string[]; <T>(list: readonly T[]): T[][] }
  • Splits a collection into slices of the specified length.

    example
    R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]]
    R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz']

    Type parameters

    • T

    Parameters

    • a: number
    • list: readonly T[]

    Returns T[][]

  • Parameters

    • a: number
    • list: string

    Returns string[]

  • Parameters

    • a: number

    Returns { (list: string): string[]; <T>(list: readonly T[]): T[][] }

      • (list: string): string[]
      • <T>(list: readonly T[]): T[][]
      • Parameters

        • list: string

        Returns string[]

      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns T[][]

  • splitWhen<T>(pred: (val: T) => boolean, list: readonly T[]): [T[], T[]]
  • splitWhen<T>(pred: (val: T) => boolean): <U>(list: readonly U[]) => [U[], U[]]
  • Takes a list and a predicate and returns a pair of lists. The first list contains all elements before (but not including) the first element for which the predicate returns a truthy value. The second list contains the rest of the elements. It will be empty if no elements satisfy the predicate.

    example
    R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]);   //=> [[1], [2, 3, 1, 2, 3]]
    

    Type parameters

    • T

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    • list: readonly T[]

    Returns [T[], T[]]

  • Type parameters

    • T

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    Returns <U>(list: readonly U[]) => [U[], U[]]

      • <U>(list: readonly U[]): [U[], U[]]
      • Type parameters

        • U: T

        Parameters

        • list: readonly U[]

        Returns [U[], U[]]

  • splitWhenever<T>(pred: (a: T) => boolean, list: T[]): T[][]
  • splitWhenever<T>(pred: (a: T) => boolean): <U>(list: U[]) => U[][]
  • Splits an array into slices on every occurrence of a value.

    example
    R.splitWhenever(R.equals(2), [1, 2, 3, 2, 4, 5, 2, 6, 7]); //=> [[1], [3], [4, 5], [6, 7]]
    

    Type parameters

    • T

    Parameters

    • pred: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: T[]

    Returns T[][]

  • Type parameters

    • T

    Parameters

    • pred: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns <U>(list: U[]) => U[][]

      • <U>(list: U[]): U[][]
      • Type parameters

        • U: T

        Parameters

        • list: U[]

        Returns U[][]

  • startsWith(substr: string, str: string): boolean
  • startsWith(substr: string): (str: string) => boolean
  • startsWith<T>(subList: readonly T[], list: readonly T[]): boolean
  • startsWith<T>(subList: readonly T[]): (list: readonly T[]) => boolean
  • Checks if a list starts with the provided sublist.

    Similarly, checks if a string starts with the provided substring.

    See also endsWith.

    example
    R.startsWith('a', 'abc')                //=> true
    R.startsWith('b', 'abc') //=> false
    R.startsWith(['a'], ['a', 'b', 'c']) //=> true
    R.startsWith(['b'], ['a', 'b', 'c']) //=> false

    Parameters

    • substr: string
    • str: string

    Returns boolean

  • Parameters

    • substr: string

    Returns (str: string) => boolean

      • (str: string): boolean
      • Parameters

        • str: string

        Returns boolean

  • Type parameters

    • T

    Parameters

    • subList: readonly T[]
    • list: readonly T[]

    Returns boolean

  • Type parameters

    • T

    Parameters

    • subList: readonly T[]

    Returns (list: readonly T[]) => boolean

      • (list: readonly T[]): boolean
      • Parameters

        • list: readonly T[]

        Returns boolean

  • subtract(__: Placeholder, b: number): (a: number) => number
  • subtract(__: Placeholder): (b: number, a: number) => number
  • subtract(a: number, b: number): number
  • subtract(a: number): (b: number) => number
  • Subtracts two numbers. Equivalent to a - b but curried.

    example
    R.subtract(10, 8); //=> 2

    const minus5 = R.subtract(R.__, 5);
    minus5(17); //=> 12

    const complementaryAngle = R.subtract(90);
    complementaryAngle(30); //=> 60
    complementaryAngle(72); //=> 18

    Parameters

    Returns (a: number) => number

      • (a: number): number
      • Subtracts two numbers. Equivalent to a - b but curried.

        example
        R.subtract(10, 8); //=> 2

        const minus5 = R.subtract(R.__, 5);
        minus5(17); //=> 12

        const complementaryAngle = R.subtract(90);
        complementaryAngle(30); //=> 60
        complementaryAngle(72); //=> 18

        Parameters

        • a: number

        Returns number

  • Parameters

    Returns (b: number, a: number) => number

      • (b: number, a: number): number
      • Parameters

        • b: number
        • a: number

        Returns number

  • Parameters

    • a: number
    • b: number

    Returns number

  • Parameters

    • a: number

    Returns (b: number) => number

      • (b: number): number
      • Parameters

        • b: number

        Returns number

  • sum(list: readonly number[]): number
  • Adds together all the elements of a list.

    See also reduce.

    example
    R.sum([2,4,6,8,100,1]); //=> 121
    

    Parameters

    • list: readonly number[]

    Returns number

  • symmetricDifference<T>(list1: readonly T[], list2: readonly T[]): T[]
  • symmetricDifference<T>(list: readonly T[]): <T>(list: readonly T[]) => T[]
  • Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both.

    example
    R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5]
    R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2]

    Type parameters

    • T

    Parameters

    • list1: readonly T[]
    • list2: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • list: readonly T[]

    Returns <T>(list: readonly T[]) => T[]

      • <T>(list: readonly T[]): T[]
      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns T[]

  • symmetricDifferenceWith<T>(pred: (a: T, b: T) => boolean, list1: readonly T[], list2: readonly T[]): T[]
  • symmetricDifferenceWith<T>(pred: (a: T, b: T) => boolean): _.F.Curry<(a: readonly T[], b: readonly T[]) => T[]>
  • Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both. Duplication is determined according to the value returned by applying the supplied predicate to two list elements.

    example
    const eqA = R.eqBy(R.prop<'a', number>('a'));
    const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}];
    const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}];
    R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}]

    Type parameters

    • T

    Parameters

    • pred: (a: T, b: T) => boolean
        • (a: T, b: T): boolean
        • Parameters

          • a: T
          • b: T

          Returns boolean

    • list1: readonly T[]
    • list2: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • pred: (a: T, b: T) => boolean
        • (a: T, b: T): boolean
        • Parameters

          • a: T
          • b: T

          Returns boolean

    Returns _.F.Curry<(a: readonly T[], b: readonly T[]) => T[]>

  • tail(list: string): string
  • tail<T>(list: readonly T[]): T[]
  • Returns all but the first element of a list or string.

    example
    R.tail([1, 2, 3]);  //=> [2, 3]
    R.tail([1, 2]); //=> [2]
    R.tail([1]); //=> []
    R.tail([]); //=> []

    R.tail('abc'); //=> 'bc'
    R.tail('ab'); //=> 'b'
    R.tail('a'); //=> ''
    R.tail(''); //=> ''

    Parameters

    • list: string

    Returns string

  • Type parameters

    • T

    Parameters

    • list: readonly T[]

    Returns T[]

  • take<T>(n: number, xs: readonly T[]): T[]
  • take(n: number, xs: string): string
  • take(n: number): { (xs: string): string; <T>(xs: readonly T[]): T[] }
  • take<T>(n: number): (xs: readonly T[]) => T[]
  • Returns the first (at most) n elements of the given list, string, or transducer/transformer.

    Dispatches to the take method of the second argument, if present.

    See also drop.

    example
    R.take(1, ['foo', 'bar', 'baz']); //=> ['foo']
    R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
    R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
    R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
    R.take(3, 'ramda'); //=> 'ram'

    const personnel = [
    'Dave Brubeck',
    'Paul Desmond',
    'Eugene Wright',
    'Joe Morello',
    'Gerry Mulligan',
    'Bob Bates',
    'Joe Dodge',
    'Ron Crotty'
    ];

    const takeFive = R.take(5);
    takeFive(personnel);
    //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan']

    Type parameters

    • T

    Parameters

    • n: number
    • xs: readonly T[]

    Returns T[]

  • Parameters

    • n: number
    • xs: string

    Returns string

  • Parameters

    • n: number

    Returns { (xs: string): string; <T>(xs: readonly T[]): T[] }

      • (xs: string): string
      • <T>(xs: readonly T[]): T[]
      • Parameters

        • xs: string

        Returns string

      • Type parameters

        • T

        Parameters

        • xs: readonly T[]

        Returns T[]

  • Type parameters

    • T

    Parameters

    • n: number

    Returns (xs: readonly T[]) => T[]

      • (xs: readonly T[]): T[]
      • Parameters

        • xs: readonly T[]

        Returns T[]

  • takeLast<T>(n: number, xs: readonly T[]): T[]
  • takeLast(n: number, xs: string): string
  • takeLast(n: number): { (xs: string): string; <T>(xs: readonly T[]): T[] }
  • Returns a new list containing the last (at most) n elements of the given list.

    See also dropLast.

    example
    R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz']
    R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
    R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
    R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
    R.takeLast(3, 'ramda'); //=> 'mda'

    Type parameters

    • T

    Parameters

    • n: number
    • xs: readonly T[]

    Returns T[]

  • Parameters

    • n: number
    • xs: string

    Returns string

  • Parameters

    • n: number

    Returns { (xs: string): string; <T>(xs: readonly T[]): T[] }

      • (xs: string): string
      • <T>(xs: readonly T[]): T[]
      • Parameters

        • xs: string

        Returns string

      • Type parameters

        • T

        Parameters

        • xs: readonly T[]

        Returns T[]

  • takeLastWhile<T>(pred: (a: T) => boolean, list: readonly T[]): T[]
  • takeLastWhile<T>(pred: (a: T) => boolean): <T>(list: readonly T[]) => T[]
  • Returns a new list containing the last elements of a given list, passing each value to the supplied predicate function and terminating when the predicate function returns a falsy value. Excludes the element that caused the predicate function to fail.

    Type parameters

    • T

    Parameters

    • pred: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • pred: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    Returns <T>(list: readonly T[]) => T[]

      • <T>(list: readonly T[]): T[]
      • Type parameters

        • T

        Parameters

        • list: readonly T[]

        Returns T[]

  • takeWhile<T>(fn: (x: T) => boolean, list: readonly T[]): T[]
  • takeWhile<T>(fn: (x: T) => boolean): (list: readonly T[]) => T[]
  • Returns a new list containing the first elements of a given list, passing each value to the supplied predicate function, and terminating when the predicate function returns a falsy value.

    Dispatches to the takeWhile method of the second argument, if present.

    Acts as a transducer if a transformer is given in list position.

    See also dropWhile, addIndex, transduce.

    Type parameters

    • T

    Parameters

    • fn: (x: T) => boolean
        • (x: T): boolean
        • Parameters

          • x: T

          Returns boolean

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • fn: (x: T) => boolean
        • (x: T): boolean
        • Parameters

          • x: T

          Returns boolean

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • tap<T>(fn: (a: T) => void, value: T): T
  • tap<T>(fn: (a: T) => void): (value: T) => T
  • Runs the given function with the supplied object, then returns the object. Acts as a transducer if a transformer is given as second parameter.

    example
    const sayX = <T>(x: T) => console.log('x is ' + x);
    R.tap(sayX, 100); //=> 100
    // logs 'x is 100'

    Type parameters

    • T

    Parameters

    • fn: (a: T) => void
        • (a: T): void
        • Parameters

          • a: T

          Returns void

    • value: T

    Returns T

  • Type parameters

    • T

    Parameters

    • fn: (a: T) => void
        • (a: T): void
        • Parameters

          • a: T

          Returns void

    Returns (value: T) => T

      • (value: T): T
      • Parameters

        • value: T

        Returns T

  • test(regexp: RegExp, str: string): boolean
  • test(regexp: RegExp): (str: string) => boolean
  • Determines whether a given string matches a given regular expression.

    See also match.

    example
    R.test(/^x/, 'xyz'); //=> true
    R.test(/^y/, 'xyz'); //=> false

    Parameters

    • regexp: RegExp
    • str: string

    Returns boolean

  • Parameters

    • regexp: RegExp

    Returns (str: string) => boolean

      • (str: string): boolean
      • Parameters

        • str: string

        Returns boolean

  • thunkify<F>(fn: F): _.F.Curry<(...args: Parameters<F>) => () => ReturnType<F>>
  • Creates a thunk out of a function. A thunk delays a calculation until its result is needed, providing lazy evaluation of arguments.

    See also partial, partialRight.

    example
    R.thunkify(R.identity)(42)(); //=> 42
    R.thunkify((a: number, b: number) => a + b)(25, 17)(); //=> 42

    Type parameters

    Parameters

    • fn: F

    Returns _.F.Curry<(...args: Parameters<F>) => () => ReturnType<F>>

  • times<T>(fn: (i: number) => T, n: number): T[]
  • times<T>(fn: (i: number) => T): (n: number) => T[]
  • Calls an input function n times, returning an array containing the results of those function calls.

    fn is passed one argument: The current value of n, which begins at 0 and is gradually incremented to n - 1.

    See also repeat.

    example
    R.times(R.identity, 5); //=> [0, 1, 2, 3, 4]
    

    Type parameters

    • T

    Parameters

    • fn: (i: number) => T
        • (i: number): T
        • Parameters

          • i: number

          Returns T

    • n: number

    Returns T[]

  • Type parameters

    • T

    Parameters

    • fn: (i: number) => T
        • (i: number): T
        • Parameters

          • i: number

          Returns T

    Returns (n: number) => T[]

      • (n: number): T[]
      • Parameters

        • n: number

        Returns T[]

  • toLower<S>(str: S): Lowercase<S>
  • toLower(str: string): string
  • The lower case version of a string.

    See also toUpper.

    example
    R.toLower('XYZ'); //=> 'xyz'
    

    Type parameters

    • S: string

    Parameters

    • str: S

    Returns Lowercase<S>

  • Parameters

    • str: string

    Returns string

  • toPairs<O, K>(obj: O): { [ key in K]: [`${key}`, O[key]] }[K][]
  • toPairs<S>(obj: Record<string | number, S>): [string, S][]
  • Converts an object into an array of key, value arrays. Only the object's own properties are used. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.

    Type parameters

    • O: object

    • K: string | number

    Parameters

    • obj: O

    Returns { [ key in K]: [`${key}`, O[key]] }[K][]

  • Type parameters

    • S

    Parameters

    • obj: Record<string | number, S>

    Returns [string, S][]

  • toPairsIn<O, K>(obj: O): { [ key in K]: [`${key}`, O[key]] }[K][]
  • toPairsIn<S>(obj: Record<string | number, S>): [string, S][]
  • Converts an object into an array of key, value arrays. The object's own properties and prototype properties are used. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.

    See also toPairs.=

    example
    class F {
    x: string;
    y = 'Y';

    constructor() {
    this.x = 'X';
    }
    }

    const f = new F();
    R.toPairsIn(f); //=> [['x','X'], ['y','Y']]

    Type parameters

    • O: object

    • K: string | number

    Parameters

    • obj: O

    Returns { [ key in K]: [`${key}`, O[key]] }[K][]

  • Type parameters

    • S

    Parameters

    • obj: Record<string | number, S>

    Returns [string, S][]

  • toString(val: unknown): string
  • Returns the string representation of the given value. eval'ing the output should result in a value equivalent to the input value. Many of the built-in toString methods do not satisfy this requirement.

    If the given value is an Object with a toString method other than Object.prototype.toString, that method is invoked with no arguments to produce the return value. This means user-defined constructor functions can provide a suitable toString method.

    example
    class Point {
    constructor(public x: number, public y: number) {}

    toString() {
    return 'new Point(' + this.x + ', ' + this.y + ')';
    }
    }

    R.toString(new Point(1, 2)); //=> 'new Point(1, 2)'
    R.toString(42); //=> '42'
    R.toString('abc'); //=> '"abc"'
    R.toString([1, 2, 3]); //=> '[1, 2, 3]'
    R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}'
    R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")'

    Parameters

    • val: unknown

    Returns string

  • toUpper<S>(str: S): Uppercase<S>
  • toUpper(str: string): string
  • The upper case version of a string.

    See also toLower.

    example
    R.toUpper('abc'); //=> 'ABC'
    

    Type parameters

    • S: string

    Parameters

    • str: S

    Returns Uppercase<S>

  • Parameters

    • str: string

    Returns string

  • transduce<T, U, V>(xf: (arg: readonly T[]) => U[], fn: (acc: V, val: U) => V, acc: V, list: readonly T[]): V
  • transduce<T, U, V>(xf: (arg: readonly T[]) => U[]): (fn: (acc: V, val: U) => V, acc: V, list: readonly T[]) => V
  • transduce<T, U, V>(xf: (arg: readonly T[]) => U[], fn: (acc: V, val: U) => V): (acc: readonly T[], list: readonly T[]) => V
  • transduce<T, U, V>(xf: (arg: readonly T[]) => U[], fn: (acc: V, val: U) => V, acc: readonly T[]): (list: readonly T[]) => V
  • Initializes a transducer using supplied iterator function. Returns a single item by iterating through the list, successively calling the transformed iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.

    The iterator function receives two values: (acc, value). It will be wrapped as a transformer to initialize the transducer. A transformer can be passed directly in place of an iterator function. In both cases, iteration may be stopped early with the R.reduced function.

    A transducer is a function that accepts a transformer and returns a transformer and can be composed directly.

    The accumulator can also be a transformer object that provides:

    • A 2-arity iterator function, which is passed directly to reduce.
    • A 0-arity initial value function, which is used to provide the initial accumulator. This is ignored by R.transduce.
    • A 1-arity result extraction function, which is used to convert the final accumulator into the return type.

    The iteration is performed with R.reduce after initializing the transducer.

    See also reduce, reduced, into.

    example
    const numbers = [1, 2, 3, 4];
    const transducer = R.compose(R.map(R.add(1)), R.take<number>(2));
    R.transduce(transducer, R.flip<number, number[], number[]>(R.append), [], numbers); //=> [2, 3]

    const isOdd = (x: number) => x % 2 !== 0;
    const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1));
    R.transduce(firstOddTransducer, R.flip<number, number[], number[]>(R.append), [], R.range(0, 100)); //=> [1]

    Type parameters

    • T

    • U

    • V

    Parameters

    • xf: (arg: readonly T[]) => U[]
        • (arg: readonly T[]): U[]
        • Parameters

          • arg: readonly T[]

          Returns U[]

    • fn: (acc: V, val: U) => V
        • (acc: V, val: U): V
        • Parameters

          • acc: V
          • val: U

          Returns V

    • acc: V
    • list: readonly T[]

    Returns V

  • Type parameters

    • T

    • U

    • V

    Parameters

    • xf: (arg: readonly T[]) => U[]
        • (arg: readonly T[]): U[]
        • Parameters

          • arg: readonly T[]

          Returns U[]

    Returns (fn: (acc: V, val: U) => V, acc: V, list: readonly T[]) => V

      • (fn: (acc: V, val: U) => V, acc: V, list: readonly T[]): V
      • Parameters

        • fn: (acc: V, val: U) => V
            • (acc: V, val: U): V
            • Parameters

              • acc: V
              • val: U

              Returns V

        • acc: V
        • list: readonly T[]

        Returns V

  • Type parameters

    • T

    • U

    • V

    Parameters

    • xf: (arg: readonly T[]) => U[]
        • (arg: readonly T[]): U[]
        • Parameters

          • arg: readonly T[]

          Returns U[]

    • fn: (acc: V, val: U) => V
        • (acc: V, val: U): V
        • Parameters

          • acc: V
          • val: U

          Returns V

    Returns (acc: readonly T[], list: readonly T[]) => V

      • (acc: readonly T[], list: readonly T[]): V
      • Parameters

        • acc: readonly T[]
        • list: readonly T[]

        Returns V

  • Type parameters

    • T

    • U

    • V

    Parameters

    • xf: (arg: readonly T[]) => U[]
        • (arg: readonly T[]): U[]
        • Parameters

          • arg: readonly T[]

          Returns U[]

    • fn: (acc: V, val: U) => V
        • (acc: V, val: U): V
        • Parameters

          • acc: V
          • val: U

          Returns V

    • acc: readonly T[]

    Returns (list: readonly T[]) => V

      • (list: readonly T[]): V
      • Parameters

        • list: readonly T[]

        Returns V

  • transpose<T>(list: readonly T[][]): T[][]
  • Transposes the rows and columns of a 2D list. When passed a list of n lists of length x, returns a list of x lists of length n.

    example
    R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']]
    R.transpose<string | number>([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']]

    // If some of the rows are shorter than the following rows, their elements are skipped:
    R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]]

    Type parameters

    • T

    Parameters

    • list: readonly T[][]

    Returns T[][]

  • traverse<A, B>(of: (a: B) => B[], fn: (t: A) => B[], list: readonly A[]): B[][]
  • traverse<A, B>(of: (a: B) => B[], fn: (t: A) => B[]): (list: readonly A[]) => B[][]
  • traverse<A, B>(of: (a: B) => B[]): (fn: (t: A) => B[], list: readonly A[]) => B[][]
  • Maps an Applicative-returning function over a Traversable, then uses R.sequence to transform the resulting Traversable of Applicative into an Applicative of Traversable.

    Dispatches to the traverse method of the third argument, if present.

    See also {@link sequence}.

    example
    // Returns `[]` if the given divisor is `0`
    const safeDiv = (n: number) => (d: number) => d === 0 ? [] : Array.of(n / d)

    R.traverse(Array.of, safeDiv(10), [2, 4, 5]); //=> [[5, 2.5, 2]]
    R.traverse(Array.of, safeDiv(10), [2, 0, 5]); //=> []

    Type parameters

    • A

    • B

    Parameters

    • of: (a: B) => B[]
        • (a: B): B[]
        • Parameters

          • a: B

          Returns B[]

    • fn: (t: A) => B[]
        • (t: A): B[]
        • Parameters

          • t: A

          Returns B[]

    • list: readonly A[]

    Returns B[][]

  • Type parameters

    • A

    • B

    Parameters

    • of: (a: B) => B[]
        • (a: B): B[]
        • Parameters

          • a: B

          Returns B[]

    • fn: (t: A) => B[]
        • (t: A): B[]
        • Parameters

          • t: A

          Returns B[]

    Returns (list: readonly A[]) => B[][]

      • (list: readonly A[]): B[][]
      • Parameters

        • list: readonly A[]

        Returns B[][]

  • Type parameters

    • A

    • B

    Parameters

    • of: (a: B) => B[]
        • (a: B): B[]
        • Parameters

          • a: B

          Returns B[]

    Returns (fn: (t: A) => B[], list: readonly A[]) => B[][]

      • (fn: (t: A) => B[], list: readonly A[]): B[][]
      • Parameters

        • fn: (t: A) => B[]
            • (t: A): B[]
            • Parameters

              • t: A

              Returns B[]

        • list: readonly A[]

        Returns B[][]

  • trim(str: string): string
  • Removes (strips) whitespace from both ends of the string.

    example
    R.trim('   xyz  '); //=> 'xyz'
    R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z']

    Parameters

    • str: string

    Returns string

  • tryCatch<F, RE, E>(tryer: F, catcher: (error: E, ...args: Parameters<F>) => RE): F | (() => RE)
  • tryCatch<F>(tryer: F): <RE, E>(catcher: (error: E, ...args: _.F.Parameters<F>) => RE) => F | (() => RE)
  • R.tryCatch takes two functions, a tryer and a catcher. The returned function evaluates the tryer; if it does not throw, it simply returns the result. If the tryer does throw, the returned function evaluates the catcher function and returns its result.

    note

    For effective composition with this function, both the tryer and catcher functions must return the same type of results.

    example
    R.tryCatch(R.prop('x'), R.F)({ x: true }); //=> true
    R.tryCatch((_s: string) => { throw 'foo' }, R.always('caught'))('bar') //=> 'caught'
    // Don't do this, it's just an example
    R.tryCatch(R.times(R.identity), R.always([]))('s' as never) //=> []
    R.tryCatch((_s: string) => { throw 'this is not a valid value' }, (err, value)=>({ error: err, value }))('bar')
    //=> {'error': 'this is not a valid value', 'value': 'bar'}

    Type parameters

    Parameters

    • tryer: F
    • catcher: (error: E, ...args: Parameters<F>) => RE
        • (error: E, ...args: Parameters<F>): RE
        • Parameters

          • error: E
          • Rest ...args: Parameters<F>

          Returns RE

    Returns F | (() => RE)

  • Type parameters

    Parameters

    • tryer: F

    Returns <RE, E>(catcher: (error: E, ...args: _.F.Parameters<F>) => RE) => F | (() => RE)

      • <RE, E>(catcher: (error: E, ...args: _.F.Parameters<F>) => RE): F | (() => RE)
      • Type parameters

        • RE = ReturnType<F>

        • E = unknown

        Parameters

        • catcher: (error: E, ...args: _.F.Parameters<F>) => RE
            • (error: E, ...args: _.F.Parameters<F>): RE
            • Parameters

              • error: E
              • Rest ...args: _.F.Parameters<F>

              Returns RE

        Returns F | (() => RE)

  • type(val: any): "Object" | "Number" | "Boolean" | "String" | "Null" | "Array" | "RegExp" | "Function" | "Undefined" | "Symbol" | "Error"
  • Gives a single-word string description of the (native) type of a value, returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not attempt to distinguish user Object types any further, reporting them all as 'Object'.

    Uses Object.prototype.toString internally for values other than null and undefined.

    example
    R.type({}); //=> "Object"
    R.type(1); //=> "Number"
    R.type(false); //=> "Boolean"
    R.type('s'); //=> "String"
    R.type(null); //=> "Null"
    R.type([]); //=> "Array"
    R.type(/[A-z]/); //=> "RegExp"
    R.type(() => {}); //=> "Function"
    R.type(undefined); //=> "Undefined"

    Parameters

    • val: any

    Returns "Object" | "Number" | "Boolean" | "String" | "Null" | "Array" | "RegExp" | "Function" | "Undefined" | "Symbol" | "Error"

  • unapply<T>(fn: (args: any[]) => T): (...args: unknown[]) => T
  • Takes a function fn, which takes a single array argument, and returns a function which:

    • takes any number of positional arguments;
    • passes these arguments to fn as an array; and
    • returns the result.

    In other words, R.unapply derives a variadic function from a function which takes an array. R.unapply is the inverse of R.apply.

    See also apply.

    example
    R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]'
    

    Type parameters

    • T

    Parameters

    • fn: (args: any[]) => T
        • (args: any[]): T
        • Parameters

          • args: any[]

          Returns T

    Returns (...args: unknown[]) => T

      • (...args: unknown[]): T
      • Takes a function fn, which takes a single array argument, and returns a function which:

        • takes any number of positional arguments;
        • passes these arguments to fn as an array; and
        • returns the result.

        In other words, R.unapply derives a variadic function from a function which takes an array. R.unapply is the inverse of R.apply.

        See also apply.

        example
        R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]'
        

        Parameters

        • Rest ...args: unknown[]

        Returns T

  • unary<T, R>(fn: (a: T, ...args: any[]) => R): (a: T) => R
  • Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter. Any extraneous parameters will not be passed to the supplied function.

    See also binary, nAry.

    example
    const takesTwoArgs = <T, U>(a: T, b: U) => [a, b];
    takesTwoArgs.length; //=> 2
    takesTwoArgs(1, 2); //=> [1, 2]

    const takesOneArg = R.unary(takesTwoArgs);
    takesOneArg.length; //=> 1
    // Only 1 argument is passed to the wrapped function
    takesOneArg(1); //=> [1, undefined]

    Type parameters

    • T

    • R

    Parameters

    • fn: (a: T, ...args: any[]) => R
        • (a: T, ...args: any[]): R
        • Parameters

          • a: T
          • Rest ...args: any[]

          Returns R

    Returns (a: T) => R

      • (a: T): R
      • Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter. Any extraneous parameters will not be passed to the supplied function.

        See also binary, nAry.

        example
        const takesTwoArgs = <T, U>(a: T, b: U) => [a, b];
        takesTwoArgs.length; //=> 2
        takesTwoArgs(1, 2); //=> [1, 2]

        const takesOneArg = R.unary(takesTwoArgs);
        takesOneArg.length; //=> 1
        // Only 1 argument is passed to the wrapped function
        takesOneArg(1); //=> [1, undefined]

        Parameters

        • a: T

        Returns R

  • uncurryN<T>(len: number, fn: (a: any) => any): (...args: unknown[]) => T
  • Returns a function of arity n from a (manually) curried function.

    note

    The returned function is actually a ramda style curryied function, which can accept one or more arguments in each function calling.

    example
    const addFour = (a: number) => (b: number) => (c: number) => (d: number) => a + b + c + d;

    const uncurriedAddFour = R.uncurryN<number>(4, addFour);
    uncurriedAddFour(1, 2, 3, 4); //=> 10

    Type parameters

    • T

    Parameters

    • len: number
    • fn: (a: any) => any
        • (a: any): any
        • Parameters

          • a: any

          Returns any

    Returns (...args: unknown[]) => T

      • (...args: unknown[]): T
      • Returns a function of arity n from a (manually) curried function.

        note

        The returned function is actually a ramda style curryied function, which can accept one or more arguments in each function calling.

        example
        const addFour = (a: number) => (b: number) => (c: number) => (d: number) => a + b + c + d;

        const uncurriedAddFour = R.uncurryN<number>(4, addFour);
        uncurriedAddFour(1, 2, 3, 4); //=> 10

        Parameters

        • Rest ...args: unknown[]

        Returns T

  • unfold<T, TResult>(fn: (seed: T) => false | [TResult, T], seed: T): TResult[]
  • unfold<T, TResult>(fn: (seed: T) => false | [TResult, T]): (seed: T) => TResult[]
  • Builds a list from a seed value. Accepts an iterator function, which returns either a falsy value to stop iteration or an array of length 2 containing the value to add to the resulting list and the seed to be used in the next call to the iterator function.

    example
    const f = (n: number) => n > 50 ? false : [-n, n + 10] as const;
    R.unfold(f, 10); //=> [-10, -20, -30, -40, -50]

    Type parameters

    • T

    • TResult

    Parameters

    • fn: (seed: T) => false | [TResult, T]
        • (seed: T): false | [TResult, T]
        • Parameters

          • seed: T

          Returns false | [TResult, T]

    • seed: T

    Returns TResult[]

  • Type parameters

    • T

    • TResult

    Parameters

    • fn: (seed: T) => false | [TResult, T]
        • (seed: T): false | [TResult, T]
        • Parameters

          • seed: T

          Returns false | [TResult, T]

    Returns (seed: T) => TResult[]

      • (seed: T): TResult[]
      • Parameters

        • seed: T

        Returns TResult[]

  • union<T>(as: readonly T[], bs: readonly T[]): T[]
  • union<T>(as: readonly T[]): (bs: readonly T[]) => T[]
  • Combines two lists into a set (i.e. no duplicates) composed of the elements of each list.

    example
    R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4]
    

    Type parameters

    • T

    Parameters

    • as: readonly T[]
    • bs: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • as: readonly T[]

    Returns (bs: readonly T[]) => T[]

      • (bs: readonly T[]): T[]
      • Parameters

        • bs: readonly T[]

        Returns T[]

  • unionWith<T>(pred: (a: T, b: T) => boolean, list1: readonly T[], list2: readonly T[]): T[]
  • unionWith<T>(pred: (a: T, b: T) => boolean): _.F.Curry<(a: readonly T[], b: readonly T[]) => T[]>
  • Combines two lists into a set (i.e. no duplicates) composed of the elements of each list. Duplication is determined according to the value returned by applying the supplied predicate to two list elements. If an element exists in both lists, the first element from the first list will be used.

    example
    const l1 = [{a: 1}, {a: 2}];
    const l2 = [{a: 1}, {a: 4}];
    R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}]

    Type parameters

    • T

    Parameters

    • pred: (a: T, b: T) => boolean
        • (a: T, b: T): boolean
        • Parameters

          • a: T
          • b: T

          Returns boolean

    • list1: readonly T[]
    • list2: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • pred: (a: T, b: T) => boolean
        • (a: T, b: T): boolean
        • Parameters

          • a: T
          • b: T

          Returns boolean

    Returns _.F.Curry<(a: readonly T[], b: readonly T[]) => T[]>

  • uniq<T>(list: readonly T[]): T[]
  • Returns a new list containing only one copy of each element in the original list.

    example
    R.uniq([1, 1, 2, 1]); //=> [1, 2]
    R.uniq([1, '1']); //=> [1, '1']
    R.uniq([[42], [42]]); //=> <a href="common.web3.uniswap_sdk.html#WETH.__type.42">42</a>

    Type parameters

    • T

    Parameters

    • list: readonly T[]

    Returns T[]

  • uniqBy<T, U>(fn: (a: T) => U, list: readonly T[]): T[]
  • uniqBy<T, U>(fn: (a: T) => U): (list: readonly T[]) => T[]
  • Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied function to each list element. Prefers the first item if the supplied function produces the same value on two items. R.equals is used for comparison.

    example
    R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10]
    

    Type parameters

    • T

    • U

    Parameters

    • fn: (a: T) => U
        • (a: T): U
        • Parameters

          • a: T

          Returns U

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    • U

    Parameters

    • fn: (a: T) => U
        • (a: T): U
        • Parameters

          • a: T

          Returns U

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • uniqWith<T, U>(pred: (x: T, y: T) => boolean, list: readonly T[]): T[]
  • uniqWith<T, U>(pred: (x: T, y: T) => boolean): (list: readonly T[]) => T[]
  • Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied predicate to two list elements. Prefers the first item if two items compare equal based on the predicate.

    Acts as a transducer if a transformer is given in list position.

    See also transduce.

    example
    const strEq = R.eqBy(String);
    R.uniqWith(strEq)([1, '1', 2, 1]); //=> [1, 2]
    R.uniqWith(strEq)([{}, {}]); //=> [{}]
    R.uniqWith(strEq)([1, '1', 1]); //=> [1]
    R.uniqWith(strEq)(['1', 1, 1]); //=> ['1']

    Type parameters

    • T

    • U

    Parameters

    • pred: (x: T, y: T) => boolean
        • (x: T, y: T): boolean
        • Parameters

          • x: T
          • y: T

          Returns boolean

    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    • U

    Parameters

    • pred: (x: T, y: T) => boolean
        • (x: T, y: T): boolean
        • Parameters

          • x: T
          • y: T

          Returns boolean

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • unless<T, U>(pred: (a: T) => boolean, whenFalseFn: (a: T) => U, a: T): T | U
  • unless<T, U>(pred: (a: T) => boolean, whenFalseFn: (a: T) => U): (a: T) => T | U
  • Tests the final argument by passing it to the given predicate function. If the predicate is not satisfied, the function will return the result of calling the whenFalseFn function with the same argument. If the predicate is satisfied, the argument is returned as is.

    See also ifElse, when, cond.

    example
    let safeInc = R.unless<number | null | undefined, null | undefined>(R.isNil, R.inc);
    safeInc(null); //=> null
    safeInc(1); //=> 2

    Type parameters

    • T

    • U

    Parameters

    • pred: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • whenFalseFn: (a: T) => U
        • (a: T): U
        • Parameters

          • a: T

          Returns U

    • a: T

    Returns T | U

  • Type parameters

    • T

    • U

    Parameters

    • pred: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • whenFalseFn: (a: T) => U
        • (a: T): U
        • Parameters

          • a: T

          Returns U

    Returns (a: T) => T | U

      • (a: T): T | U
      • Parameters

        • a: T

        Returns T | U

  • unnest<T>(list: T): _.T.UnNest<T>
  • Shorthand for R.chain(R.identity), which removes one level of nesting from any Chain.

    See also flatten, chain.

    example
    R.unnest([1, [2], <a href="common.web3.uniswap_sdk.html#WETH.__type.3">3</a>]); //=> [1, 2, [3]]
    R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6]

    Type parameters

    • T: readonly any[]

    Parameters

    • list: T

    Returns _.T.UnNest<T>

  • until<T, U>(pred: (val: T) => boolean, fn: (val: T) => U, init: U): U
  • until<T, U>(pred: (val: T) => boolean, fn: (val: T) => U): (init: U) => U
  • Takes a predicate, a transformation function, and an initial value, and returns a value of the same type as the initial value. It does so by applying the transformation until the predicate is satisfied, at which point it returns the satisfactory value.

    example
    R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128
    

    Type parameters

    • T

    • U

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    • fn: (val: T) => U
        • (val: T): U
        • Parameters

          • val: T

          Returns U

    • init: U

    Returns U

  • Type parameters

    • T

    • U

    Parameters

    • pred: (val: T) => boolean
        • (val: T): boolean
        • Parameters

          • val: T

          Returns boolean

    • fn: (val: T) => U
        • (val: T): U
        • Parameters

          • val: T

          Returns U

    Returns (init: U) => U

      • (init: U): U
      • Parameters

        • init: U

        Returns U

  • update<T>(index: number, value: T, list: readonly T[]): T[]
  • update<T>(index: number, value: T): (list: readonly T[]) => T[]
  • Returns a new copy of the array with the element at the provided index replaced with the given value.

    See also adjust.

    example
    R.update(1, '_', ['a', 'b', 'c']);      //=> ['a', '_', 'c']
    R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_']

    Type parameters

    • T

    Parameters

    • index: number
    • value: T
    • list: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • index: number
    • value: T

    Returns (list: readonly T[]) => T[]

      • (list: readonly T[]): T[]
      • Parameters

        • list: readonly T[]

        Returns T[]

  • useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TArg4, TR4, TArg5, TR5, TArg6, TR6, TArg7, TR7, TResult, RestFunctions, TArgs>(fn: (...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7, ...ReturnTypesOfFns<RestFunctions>[]]) => TResult, transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4, (arg: TArg5) => TR5, (arg: TArg6) => TR6, (arg: TArg7) => TR7, ...RestFunctions[]]): (...args: TArgs) => TResult
  • useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TArg4, TR4, TArg5, TR5, TArg6, TR6, TArg7, TR7, TResult>(fn: (...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7] & { length: 7 }) => TResult, transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4, (arg: TArg5) => TR5, (arg: TArg6) => TR6, (arg: TArg7) => TR7]): (...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg7]) => TResult
  • useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TArg4, TR4, TArg5, TR5, TArg6, TR6, TResult>(fn: (...args: [TR1, TR2, TR3, TR4, TR5, TR6] & { length: 6 }) => TResult, transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4, (arg: TArg5) => TR5, (arg: TArg6) => TR6]): (...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg6]) => TResult
  • useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TArg4, TR4, TArg5, TR5, TResult>(fn: (...args: [TR1, TR2, TR3, TR4, TR5] & { length: 5 }) => TResult, transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4, (arg: TArg5) => TR5]): (...args: [TArg1, TArg2, TArg3, TArg4, TArg5]) => TResult
  • useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TArg4, TR4, TResult>(fn: (...args: [TR1, TR2, TR3, TR4] & { length: 4 }) => TResult, transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4]): (...args: [TArg1, TArg2, TArg3, TArg4]) => TResult
  • useWith<TArg1, TR1, TArg2, TR2, TArg3, TR3, TResult>(fn: (...args: [TR1, TR2, TR3] & { length: 3 }) => TResult, transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3]): (...args: [TArg1, TArg2, TArg3]) => TResult
  • useWith<TArg1, TR1, TArg2, TR2, TResult>(fn: (...args: [TR1, TR2] & { length: 2 }) => TResult, transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2]): (...args: [TArg1, TArg2]) => TResult
  • useWith<TArg1, TR1, TResult>(fn: (...args: [TR1]) => TResult, transformers: [(arg: TArg1) => TR1]): (...args: [TArg1]) => TResult
  • Accepts a function fn and a list of transformer functions and returns a new curried function. When the new function is invoked, it calls the function fn with parameters consisting of the result of calling each supplied handler on successive arguments to the new function.

    If more arguments are passed to the returned function than transformer functions, those arguments are passed directly to fn as additional parameters. If you expect additional arguments that don't need to be transformed, although you can ignore them, it's best to pass an identity function so that the new function reports the correct arity.

    See also converge.

    example
    R.useWith(Math.pow, [(n: number) => n, (n: number) => n])(3, 4); //=> 81
    R.useWith(Math.pow, [(n: number) => n, (n: number) => n])(3)(4); //=> 81
    R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32
    R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32

    Type parameters

    • TArg1

    • TR1

    • TArg2

    • TR2

    • TArg3

    • TR3

    • TArg4

    • TR4

    • TArg5

    • TR5

    • TArg6

    • TR6

    • TArg7

    • TR7

    • TResult

    • RestFunctions: AnyFunction[]

    • TArgs: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, ...InputTypesOfFns<RestFunctions>[]]

    Parameters

    • fn: (...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7, ...ReturnTypesOfFns<RestFunctions>[]]) => TResult
        • (...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7, ...ReturnTypesOfFns<RestFunctions>[]]): TResult
        • Parameters

          • Rest ...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7, ...ReturnTypesOfFns<RestFunctions>[]]

          Returns TResult

    • transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4, (arg: TArg5) => TR5, (arg: TArg6) => TR6, (arg: TArg7) => TR7, ...RestFunctions[]]

    Returns (...args: TArgs) => TResult

      • (...args: TArgs): TResult
      • Accepts a function fn and a list of transformer functions and returns a new curried function. When the new function is invoked, it calls the function fn with parameters consisting of the result of calling each supplied handler on successive arguments to the new function.

        If more arguments are passed to the returned function than transformer functions, those arguments are passed directly to fn as additional parameters. If you expect additional arguments that don't need to be transformed, although you can ignore them, it's best to pass an identity function so that the new function reports the correct arity.

        See also converge.

        example
        R.useWith(Math.pow, [(n: number) => n, (n: number) => n])(3, 4); //=> 81
        R.useWith(Math.pow, [(n: number) => n, (n: number) => n])(3)(4); //=> 81
        R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32
        R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32

        Parameters

        • Rest ...args: TArgs

        Returns TResult

  • Type parameters

    • TArg1

    • TR1

    • TArg2

    • TR2

    • TArg3

    • TR3

    • TArg4

    • TR4

    • TArg5

    • TR5

    • TArg6

    • TR6

    • TArg7

    • TR7

    • TResult

    Parameters

    • fn: (...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7] & { length: 7 }) => TResult
        • (...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7] & { length: 7 }): TResult
        • Parameters

          • Rest ...args: [TR1, TR2, TR3, TR4, TR5, TR6, TR7] & { length: 7 }

          Returns TResult

    • transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4, (arg: TArg5) => TR5, (arg: TArg6) => TR6, (arg: TArg7) => TR7]

    Returns (...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg7]) => TResult

      • (...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg7]): TResult
      • Parameters

        • Rest ...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg7]

        Returns TResult

  • Type parameters

    • TArg1

    • TR1

    • TArg2

    • TR2

    • TArg3

    • TR3

    • TArg4

    • TR4

    • TArg5

    • TR5

    • TArg6

    • TR6

    • TResult

    Parameters

    • fn: (...args: [TR1, TR2, TR3, TR4, TR5, TR6] & { length: 6 }) => TResult
        • (...args: [TR1, TR2, TR3, TR4, TR5, TR6] & { length: 6 }): TResult
        • Parameters

          • Rest ...args: [TR1, TR2, TR3, TR4, TR5, TR6] & { length: 6 }

          Returns TResult

    • transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4, (arg: TArg5) => TR5, (arg: TArg6) => TR6]

    Returns (...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg6]) => TResult

      • (...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg6]): TResult
      • Parameters

        • Rest ...args: [TArg1, TArg2, TArg3, TArg4, TArg5, TArg6]

        Returns TResult

  • Type parameters

    • TArg1

    • TR1

    • TArg2

    • TR2

    • TArg3

    • TR3

    • TArg4

    • TR4

    • TArg5

    • TR5

    • TResult

    Parameters

    • fn: (...args: [TR1, TR2, TR3, TR4, TR5] & { length: 5 }) => TResult
        • (...args: [TR1, TR2, TR3, TR4, TR5] & { length: 5 }): TResult
        • Parameters

          • Rest ...args: [TR1, TR2, TR3, TR4, TR5] & { length: 5 }

          Returns TResult

    • transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4, (arg: TArg5) => TR5]

    Returns (...args: [TArg1, TArg2, TArg3, TArg4, TArg5]) => TResult

      • (...args: [TArg1, TArg2, TArg3, TArg4, TArg5]): TResult
      • Parameters

        • Rest ...args: [TArg1, TArg2, TArg3, TArg4, TArg5]

        Returns TResult

  • Type parameters

    • TArg1

    • TR1

    • TArg2

    • TR2

    • TArg3

    • TR3

    • TArg4

    • TR4

    • TResult

    Parameters

    • fn: (...args: [TR1, TR2, TR3, TR4] & { length: 4 }) => TResult
        • (...args: [TR1, TR2, TR3, TR4] & { length: 4 }): TResult
        • Parameters

          • Rest ...args: [TR1, TR2, TR3, TR4] & { length: 4 }

          Returns TResult

    • transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3, (arg: TArg4) => TR4]

    Returns (...args: [TArg1, TArg2, TArg3, TArg4]) => TResult

      • (...args: [TArg1, TArg2, TArg3, TArg4]): TResult
      • Parameters

        • Rest ...args: [TArg1, TArg2, TArg3, TArg4]

        Returns TResult

  • Type parameters

    • TArg1

    • TR1

    • TArg2

    • TR2

    • TArg3

    • TR3

    • TResult

    Parameters

    • fn: (...args: [TR1, TR2, TR3] & { length: 3 }) => TResult
        • (...args: [TR1, TR2, TR3] & { length: 3 }): TResult
        • Parameters

          • Rest ...args: [TR1, TR2, TR3] & { length: 3 }

          Returns TResult

    • transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2, (arg: TArg3) => TR3]

    Returns (...args: [TArg1, TArg2, TArg3]) => TResult

      • (...args: [TArg1, TArg2, TArg3]): TResult
      • Parameters

        • Rest ...args: [TArg1, TArg2, TArg3]

        Returns TResult

  • Type parameters

    • TArg1

    • TR1

    • TArg2

    • TR2

    • TResult

    Parameters

    • fn: (...args: [TR1, TR2] & { length: 2 }) => TResult
        • (...args: [TR1, TR2] & { length: 2 }): TResult
        • Parameters

          • Rest ...args: [TR1, TR2] & { length: 2 }

          Returns TResult

    • transformers: [(arg: TArg1) => TR1, (arg: TArg2) => TR2]

    Returns (...args: [TArg1, TArg2]) => TResult

      • (...args: [TArg1, TArg2]): TResult
      • Parameters

        • Rest ...args: [TArg1, TArg2]

        Returns TResult

  • Type parameters

    • TArg1

    • TR1

    • TResult

    Parameters

    • fn: (...args: [TR1]) => TResult
        • (...args: [TR1]): TResult
        • Parameters

          • Rest ...args: [TR1]

          Returns TResult

    • transformers: [(arg: TArg1) => TR1]

    Returns (...args: [TArg1]) => TResult

      • (...args: [TArg1]): TResult
      • Parameters

        • Rest ...args: [TArg1]

        Returns TResult

  • Returns a list of all the enumerable own properties of the supplied object.

    note

    The order of the output array is not guaranteed across different JS platforms.

    See also valuesIn, keys, toPairs.

    example
    R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3]
    

    Type parameters

    • T: object

    • K: string | number | symbol

    Parameters

    • obj: T

    Returns (T[K] | ValueOfUnion<T>)[]

  • valuesIn<T>(obj: any): T[]
  • Returns a list of all the properties, including prototype properties, of the supplied object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.

    See also values, keysIn.

    example
    lass F {
    x: string;
    y = 'Y';

    constructor() {
    this.x = 'X';
    }
    }

    const f = new F();
    R.valuesIn(f); //=> ['X', 'Y']

    Type parameters

    • T

    Parameters

    • obj: any

    Returns T[]

  • view<S, A>(lens: Lens<S, A>): (obj: S) => A
  • view<S, A>(lens: Lens<S, A>, obj: S): A
  • Returns a "view" of the given data structure, determined by the given lens. The lens's focus determines which portion of the data structure is visible.

    example
    const xLens = R.lensProp('x');

    const a = {x: 1, y: 2};
    R.view(xLens, a); //=> 1
    const b = {x: 4, y: 2};
    R.view(xLens, b); //=> 4

    Type parameters

    • S

    • A

    Parameters

    Returns (obj: S) => A

      • (obj: S): A
      • Returns a "view" of the given data structure, determined by the given lens. The lens's focus determines which portion of the data structure is visible.

        example
        const xLens = R.lensProp('x');

        const a = {x: 1, y: 2};
        R.view(xLens, a); //=> 1
        const b = {x: 4, y: 2};
        R.view(xLens, b); //=> 4

        Parameters

        • obj: S

        Returns A

  • Type parameters

    • S

    • A

    Parameters

    • lens: Lens<S, A>
    • obj: S

    Returns A

  • when<T, U, V>(pred: (a: T) => a is U, whenTrueFn: (a: U) => V, a: T): T | V
  • when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U, a: T): T | U
  • when<T, U, V>(pred: (a: T) => a is U, whenTrueFn: (a: U) => V): (a: T) => T | V
  • when<T, U>(pred: (a: T) => boolean, whenTrueFn: (a: T) => U): (a: T) => T | U
  • Tests the final argument by passing it to the given predicate function. If the predicate is satisfied, the function will return the result of calling the whenTrueFn function with the same argument. If the predicate is not satisfied, the argument is returned as is.

    See also ifElse, unless, cond.

    example
    // truncate :: String -> String
    const truncate = R.when(
    R.propSatisfies(R.gt(R.__, 10), 'length'),
    R.pipe(R.take(10), R.append('…'), R.join(''))
    );
    truncate('12345'.split('')); //=> '12345'
    truncate('0123456789ABC'.split('')); //=> '0123456789…'

    Type parameters

    • T

    • U

    • V

    Parameters

    • pred: (a: T) => a is U
        • (a: T): a is U
        • Parameters

          • a: T

          Returns a is U

    • whenTrueFn: (a: U) => V
        • (a: U): V
        • Parameters

          • a: U

          Returns V

    • a: T

    Returns T | V

  • Type parameters

    • T

    • U

    Parameters

    • pred: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • whenTrueFn: (a: T) => U
        • (a: T): U
        • Parameters

          • a: T

          Returns U

    • a: T

    Returns T | U

  • Type parameters

    • T

    • U

    • V

    Parameters

    • pred: (a: T) => a is U
        • (a: T): a is U
        • Parameters

          • a: T

          Returns a is U

    • whenTrueFn: (a: U) => V
        • (a: U): V
        • Parameters

          • a: U

          Returns V

    Returns (a: T) => T | V

      • (a: T): T | V
      • Parameters

        • a: T

        Returns T | V

  • Type parameters

    • T

    • U

    Parameters

    • pred: (a: T) => boolean
        • (a: T): boolean
        • Parameters

          • a: T

          Returns boolean

    • whenTrueFn: (a: T) => U
        • (a: T): U
        • Parameters

          • a: T

          Returns U

    Returns (a: T) => T | U

      • (a: T): T | U
      • Parameters

        • a: T

        Returns T | U

  • where<T, U>(spec: T, testObj: U): boolean
  • where<T>(spec: T): <U>(testObj: U) => boolean
  • where<ObjFunc2, U>(spec: ObjFunc2, testObj: U): boolean
  • where<ObjFunc2>(spec: ObjFunc2): <U>(testObj: U) => boolean
  • Takes a spec object and a test object and returns true if the test satisfies the spec. Any property on the spec that is not a function is interpreted as an equality relation.

    If the spec has a property mapped to a function, then where evaluates the function, passing in the test object's value for the property in question, as well as the whole test object.

    R.where is well suited to declaratively expressing constraints for other functions, e.g., R.filter, R.find, R.pickWith, etc.

    Seee also propSatisfies, whereEq.

    example
    // pred :: Object -> Boolean
    const pred = R.where({
    a: R.equals('foo'),
    b: R.complement(R.equals('bar')),
    x: R.gt(R.__, 10),
    y: R.lt(R.__, 20)
    });

    pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true
    pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false
    pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false
    pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false
    pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false

    Type parameters

    • T

    • U

    Parameters

    • spec: T
    • testObj: U

    Returns boolean

  • Type parameters

    • T

    Parameters

    • spec: T

    Returns <U>(testObj: U) => boolean

      • <U>(testObj: U): boolean
      • Type parameters

        • U

        Parameters

        • testObj: U

        Returns boolean

  • Type parameters

    • ObjFunc2

    • U

    Parameters

    • spec: ObjFunc2
    • testObj: U

    Returns boolean

  • Type parameters

    • ObjFunc2

    Parameters

    • spec: ObjFunc2

    Returns <U>(testObj: U) => boolean

      • <U>(testObj: U): boolean
      • Type parameters

        • U

        Parameters

        • testObj: U

        Returns boolean

  • whereEq<T, U>(spec: T, obj: U): boolean
  • whereEq<T>(spec: T): <U>(obj: U) => boolean
  • Takes a spec object and a test object; returns true if the test satisfies the spec, false otherwise. An object satisfies the spec if, for each of the spec's own properties, accessing that property of the object gives the same value (in R.eq terms) as accessing that property of the spec.

    R.whereEq is a specialization of R.where.

    See also propEq, where.

    example
    // pred :: Object -> Boolean
    const pred = R.whereEq({a: 1, b: 2});

    pred({a: 1}); //=> false
    pred({a: 1, b: 2}); //=> true
    pred({a: 1, b: 2, c: 3}); //=> true
    pred({a: 1, b: 1}); //=> false

    Type parameters

    • T

    • U

    Parameters

    • spec: T
    • obj: U

    Returns boolean

  • Type parameters

    • T

    Parameters

    • spec: T

    Returns <U>(obj: U) => boolean

      • <U>(obj: U): boolean
      • Type parameters

        • U

        Parameters

        • obj: U

        Returns boolean

  • without<T>(list1: readonly T[], list2: readonly T[]): T[]
  • without<T>(list1: readonly T[]): (list2: readonly T[]) => T[]
  • Returns a new list without values in the first argument. R.equals is used to determine equality. Acts as a transducer if a transformer is given in list position.

    example
    R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4]
    

    Type parameters

    • T

    Parameters

    • list1: readonly T[]
    • list2: readonly T[]

    Returns T[]

  • Type parameters

    • T

    Parameters

    • list1: readonly T[]

    Returns (list2: readonly T[]) => T[]

      • (list2: readonly T[]): T[]
      • Parameters

        • list2: readonly T[]

        Returns T[]

  • xor(a: any, b: any): boolean
  • xor(a: any): (b: any) => boolean
  • Exclusive disjunction logical operation. Returns true if one of the arguments is truthy and the other is falsy. Otherwise, it returns false.

    See also or, and.

    example
    R.xor(true, true); //=> false
    R.xor(true, false); //=> true
    R.xor(false, true); //=> true
    R.xor(false, false); //=> false

    Parameters

    • a: any
    • b: any

    Returns boolean

  • Parameters

    • a: any

    Returns (b: any) => boolean

      • (b: any): boolean
      • Parameters

        • b: any

        Returns boolean

  • xprod<K, V>(as: readonly K[], bs: readonly V[]): KeyValuePair<K, V>[]
  • xprod<K>(as: readonly K[]): <V>(bs: readonly V[]) => KeyValuePair<K, V>[]
  • Creates a new list out of the two supplied by creating each possible pair from the lists

    Short for cross product.

    example
    R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
    

    Type parameters

    • K

    • V

    Parameters

    • as: readonly K[]
    • bs: readonly V[]

    Returns KeyValuePair<K, V>[]

  • Type parameters

    • K

    Parameters

    • as: readonly K[]

    Returns <V>(bs: readonly V[]) => KeyValuePair<K, V>[]

  • zip<K, V>(list1: readonly K[], list2: readonly V[]): KeyValuePair<K, V>[]
  • zip<K>(list1: readonly K[]): <V>(list2: readonly V[]) => KeyValuePair<K, V>[]
  • Creates a new list out of the two supplied by pairing up equally-positioned items from both lists. The returned list is truncated to the length of the shorter of the two input lists.

    note

    R.zip is equivalent to R.zipWith((a, b) => [a, b] as const).

    example
    R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']]
    

    Type parameters

    • K

    • V

    Parameters

    • list1: readonly K[]
    • list2: readonly V[]

    Returns KeyValuePair<K, V>[]

  • Type parameters

    • K

    Parameters

    • list1: readonly K[]

    Returns <V>(list2: readonly V[]) => KeyValuePair<K, V>[]

  • zipObj<T, K>(keys: readonly K[], values: readonly T[]): { [ P in K]: T }
  • zipObj<K>(keys: readonly K[]): <T>(values: readonly T[]) => { [ P in K]: T }
  • zipObj<T, K>(keys: readonly K[], values: readonly T[]): { [ P in K]: T }
  • zipObj<K>(keys: readonly K[]): <T>(values: readonly T[]) => { [ P in K]: T }
  • Creates a new object out of a list of keys and a list of values. Key/value pairing is truncated to the length of the shorter of the two lists.

    note

    R.zipObj is equivalent to R.pipe(R.zip, R.fromPairs).

    example
    R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3}
    

    Type parameters

    • T

    • K: string

    Parameters

    • keys: readonly K[]
    • values: readonly T[]

    Returns { [ P in K]: T }

  • Type parameters

    • K: string

    Parameters

    • keys: readonly K[]

    Returns <T>(values: readonly T[]) => { [ P in K]: T }

      • <T>(values: readonly T[]): { [ P in K]: T }
      • Type parameters

        • T

        Parameters

        • values: readonly T[]

        Returns { [ P in K]: T }

  • Type parameters

    • T

    • K: number

    Parameters

    • keys: readonly K[]
    • values: readonly T[]

    Returns { [ P in K]: T }

  • Type parameters

    • K: number

    Parameters

    • keys: readonly K[]

    Returns <T>(values: readonly T[]) => { [ P in K]: T }

      • <T>(values: readonly T[]): { [ P in K]: T }
      • Type parameters

        • T

        Parameters

        • values: readonly T[]

        Returns { [ P in K]: T }

  • zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult, list1: readonly T[], list2: readonly U[]): TResult[]
  • zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult, list1: readonly T[]): (list2: readonly U[]) => TResult[]
  • zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult): (list1: readonly T[], list2: readonly U[]) => TResult[]
  • Creates a new list out of the two supplied by applying the function to each equally-positioned pair in the lists.

    example
    const f = (x: number, y: string) => [x, y] as const;
    R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']);
    //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')]

    Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (x: T, y: U) => TResult
        • (x: T, y: U): TResult
        • Parameters

          • x: T
          • y: U

          Returns TResult

    • list1: readonly T[]
    • list2: readonly U[]

    Returns TResult[]

  • Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (x: T, y: U) => TResult
        • (x: T, y: U): TResult
        • Parameters

          • x: T
          • y: U

          Returns TResult

    • list1: readonly T[]

    Returns (list2: readonly U[]) => TResult[]

      • (list2: readonly U[]): TResult[]
      • Parameters

        • list2: readonly U[]

        Returns TResult[]

  • Type parameters

    • T

    • U

    • TResult

    Parameters

    • fn: (x: T, y: U) => TResult
        • (x: T, y: U): TResult
        • Parameters

          • x: T
          • y: U

          Returns TResult

    Returns (list1: readonly T[], list2: readonly U[]) => TResult[]

      • (list1: readonly T[], list2: readonly U[]): TResult[]
      • Parameters

        • list1: readonly T[]
        • list2: readonly U[]

        Returns TResult[]

Generated using TypeDoc